以下功能用于检查播放操作是否可行。如果可以播放,则返回 true false 。对于这种方法,适当的nunit测试用例应该是什么?
private bool CanPlay(object parameter)
{
if (AudioEngine != null)
{
return AudioEngine.CanPlay;
}
return false;
}
private void Play(object parameter)
{
if (AudioEngine != null && AudioEngine.ActiveStream!=null)
{
AudioEngine.Play();
}
}
[Test]
public void PlayAudioControlVMTestTrue()
{
AudioControlVm avm = new AudioControlVm();
RelayCommand command = (RelayCommand)avm.PlayCommand;
bool canPlay = command.CanExecute(avm);
Assert.IsTrue(canPlay);
}
答案 0 :(得分:0)
我做了如下:
[Test]
public void PlayAudioControlVMTestTrue()
{
AudioControlVm avm = new AudioControlVm();
NAudioEngine.Instance.OpenFile(WAV_FILE_LOCATION);
avm.AudioEngine.Play();
RelayCommand command = (RelayCommand)avm.PlayCommand;
bool canPlay = command.CanExecute(avm);
Assert.IsTrue(canPlay);
NAudioEngine.Instance.Stop();
}