Production code:
private void instrumentCollectionViewControl_ClearAllInstrument(object sender, EventArgs e)
{
this.command = new CollectiveCommand(new ClearInstrumentCollectionCommand(), new DisplayProductSelectionCommand());
this.command.Execute(this.Context);
}
Test code:
[Test]
public void instrumentCollectionViewControl_ClearAllInstrumentTest()
{
this.mockBasePage.ExpectGet("Context", this.httpContext);
Mock mockClearInstrumentCollectionCommand = MockManager.Mock(typeof(ClearInstrumentCollectionCommand));
mockClearInstrumentCollectionCommand.ExpectConstructor();
Mock mockDisplayProductSelectionCommand = MockManager.Mock(typeof(DisplayProductSelectionCommand));
mockDisplayProductSelectionCommand.ExpectConstructor();
Mock mockCollectiveCommand = MockManager.Mock(typeof(CollectiveCommand));
mockCollectiveCommand.ExpectConstructor().Args(Check.IsTypeOf(typeof(ClearInstrumentCollectionCommand)), Check.IsTypeOf(typeof(DisplayProductSelectionCommand)));
mockCollectiveCommand.ExpectCall("Execute").Args(this.httpContext);
base.InvokeMethod("instrumentCollectionViewControl_ClearAllInstrument", new object[]{null, null});
}
Result in NUnit:
Rbsfm.VTradeWeb.Presentation.Views.instrumentpricerTest.instrumentCollectionViewControl_ClearAllInstrumentTest : System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> TypeMock.VerifyException :
TypeMock Verification: Call to Rbsfm.VTradeWeb.Presentation.Core.FrontController.Commands.CollectiveCommand..ctor() 2 Parameters expected but recived 1
TearDown : TypeMock.VerifyException :
TypeMock Verification: Method Rbsfm.VTradeWeb.Presentation.Core.FrontController.Commands.CollectiveCommand.Execute() has 1 more expected calls
Method Rbsfm.VTradeWeb.Presentation.Views.instrumentpricer.get_Context() has 1 more expected calls