Raise.Event <action <t [] >>:无法使用提供的参数引发事件

时间:2019-05-07 19:17:28

标签: nunit nsubstitute

当我运行下面的单元测试时,它失败并返回此消息:

  

System.ArgumentException:无法使用提供的引发事件   论点。使用Raise.Event <Action'1>(CWaveform [])引发此事件。

[Test]
public void WaveformsReceived_FourWaveformsReceived_WaveformPlotsEqual4()
{
    IWorkflowController oWorkflowControllerMock = Substitute.For<IWorkflowController>();
    IEventAggregator oEventAggregatorMock = Substitute.For<IEventAggregator>();
    CDataAcquisitionViewModel oDataAcquisitionViewModel = new CDataAcquisitionViewModel(oWorkflowControllerMock, oEventAggregatorMock);

    CWaveform[] aoWaveforms = { };
    oWorkflowControllerMock.WaveformsReceived += aoWForms => aoWaveforms = aoWForms;
    int nNumberOfWaveforms = 4;
    CWaveform[] aoFourWaveforms = Enumerable.Range(0, nNumberOfWaveforms).Select(_ => new CWaveform()).ToArray();
    oWorkflowControllerMock.WaveformsReceived += Raise.Event<Action<CWaveform[]>>(aoFourWaveforms);

    Assert.AreEqual(aoWaveforms.Length, oDataAcquisitionViewModel.Plots.Count());
}

Raise.Event似乎不适用于其参数是引用类型数组的Action。它确实适用于值类型数组。是否可以使其适用于引用类型?

编辑:IWorkflowController.WaveformsReceived的声明类型为事件操作<CWaveform[]>

0 个答案:

没有答案