using System;
using System.Threading.Tasks;
using NavisworksTransport.UI.WPF.ViewModels;
namespace NavisworksTransport.UnitTests
{
///
/// 用于测试的ViewModelBase实现
///
public class TestViewModel : ViewModelBase
{
private string _testProperty;
public string TestProperty
{
get => _testProperty;
set => SetProperty(ref _testProperty, value);
}
///
/// 公开OnPropertyChanged方法用于测试
///
public void TriggerPropertyChanged(string propertyName)
{
OnPropertyChanged(propertyName);
}
///
/// 公开OnPropertiesChanged方法用于测试
///
public void TriggerPropertiesChanged(params string[] propertyNames)
{
OnPropertiesChanged(propertyNames);
}
///
/// 公开SetProperties方法用于测试
///
public void TriggerSetProperties(params (string name, object value)[] properties)
{
SetProperties(properties);
}
///
/// 公开OnPropertyChangedAsync方法用于测试
///
public async Task TriggerPropertyChangedAsync(string propertyName, int timeout = 3000)
{
await OnPropertyChangedAsync(propertyName, timeout);
}
///
/// 公开SafeExecute方法用于测试
///
public void TestSafeExecute(Action action, string operationName)
{
SafeExecute(action, operationName);
}
///
/// 公开SafeExecute方法用于测试
///
public T TestSafeExecuteWithReturn(Func func, T defaultValue, string operationName)
{
return SafeExecute(func, defaultValue, operationName);
}
///
/// 公开SafeExecuteAsync方法用于测试
///
public async Task TestSafeExecuteAsync(Action action, string operationName)
{
await SafeExecuteAsync(action, operationName);
}
}
}