NAudioEngine是一个单例类,如何编写可以执行以下代码片段:
private bool CanAddNew(object parameter)
{
if (NAudioEngine.Instance.SelectionEnd.Milliseconds != 0)
{
return true;
}
return false;
}
[Test]
public void AddNewCommandMainVMTestTrue()
{
MainVm mainVM = new MainVm();
RelayCommand command = (RelayCommand)mainVM.AddNewCommand;
bool canAddNew = command.CanExecute(null);
Assert.IsTrue(canAddNew);
}
答案 0 :(得分:0)
[Test]
public void AddNewCommandMainVMTest()
{
NAudioEngine.Instance.OpenFile(WAV_FILE);
NAudioEngine.Instance.SelectionBegin = new TimeSpan(0, 0, 0);
NAudioEngine.Instance.SelectionEnd = new TimeSpan(0, 0, 0);
MainVm mainVM = new MainVm();
RelayCommand command = (RelayCommand)mainVM.AddNewCommand;
bool canAddNew = command.CanExecute(mainVM);
Assert.IsFalse(canAddNew);
}