public void TestCommandRegister3() { Command command = new Command(); int result = 0; CommandRegisterReturn <ICallTester, int, byte, float, int> cr = new CommandRegisterReturn <ICallTester, int, byte, float, int>( command, (caller, arg1, arg2, arg3) => caller.Function4(arg1, arg2, arg3), ret => { result = ret; }); ICallTester callTester = Substitute.For <ICallTester>(); callTester.Function4(Arg.Any <int>(), Arg.Any <byte>(), Arg.Any <float>()).Returns(1); cr.Register(0, callTester); command.Run( "0Function4", new[] { "1", "2", "3" }); callTester.Received(1).Function4(Arg.Any <int>(), Arg.Any <byte>(), Arg.Any <float>()); cr.Unregister(0); NUnit.Framework.Assert.AreEqual(1, result); }
public void TestCommandRegister0() { ICallTester callTester = Substitute.For <ICallTester>(); Command command = new Command(); CommandRegister <ICallTester> cr = new CommandRegister <ICallTester>(command, caller => caller.Function1()); cr.Register(0, callTester); command.Run("0Function1", new string[0]); callTester.Received(1).Function1(); cr.Unregister(0); }
public void TestCommandRegister2() { Command command = new Command(); CommandRegisterReturn <ICallTester, int> cr = new CommandRegisterReturn <ICallTester, int>( command, caller => caller.Function3(), ret => { }); ICallTester callTester = Substitute.For <ICallTester>(); cr.Register(0, callTester); command.Run( "0Function3", new string[] { }); callTester.Received(1).Function3(); cr.Unregister(0); }