Example #1
0
        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);
        }
Example #2
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);
        }
Example #3
0
        public void TestCommandRegister4()
        {
            Command command = new Command();
            int     result  = 0;
            CommandRegisterReturn <ICallTester, int> cr = new CommandRegisterReturn <ICallTester, int>(

                command,
                (caller) => caller.Function5,
                ret => { result = ret; });
            ICallTester callTester = Substitute.For <ICallTester>();

            callTester.Function5.Returns(1);
            cr.Register(0, callTester);
            command.Run(
                "0Function5",
                new string[0]);

            cr.Unregister(0);

            NUnit.Framework.Assert.AreEqual(1, result);
        }
Example #4
0
        public void TestCommandRegister4()
        {
            var command = new Command();
            int result = 0;
            var cr = new CommandRegisterReturn<ICallTester,  int>(

                command,
                (caller) => caller.Function5,
                ret => { result = ret; });
            var callTester = Substitute.For<ICallTester>();
            callTester.Function5.Returns(1);
            cr.Register(callTester);
            command.Run(
                "Function5",
                new string[0]);

            cr.Unregister();

            Assert.AreEqual(1 , result);
        }
Example #5
0
        public void TestCommandRegister3()
        {
            var command = new Command();
            var cr = new CommandRegisterReturn<ICallTester, int, byte, float, int>(

                command,
                (caller, arg1, arg2, arg3) => caller.Function4(arg1, arg2, arg3),
                ret => { });
            var callTester = Substitute.For<ICallTester>();
            cr.Register(callTester);
            command.Run(
                "Function4",
                new[]
                {
                    "1",
                    "2",
                    "3"
                });
            callTester.Received(1).Function4(Arg.Any<int>(), Arg.Any<byte>(), Arg.Any<float>());
            cr.Unregister();
        }
Example #6
0
        public void TestCommandRegister2()
        {
            var command = new Command();
            var cr = new CommandRegisterReturn<ICallTester, int>(

                command,
                caller => caller.Function3(),
                ret => { });
            var callTester = Substitute.For<ICallTester>();
            cr.Register(callTester);
            command.Run(
                "Function3",
                new string[]
                {
                });
            callTester.Received(1).Function3();
            cr.Unregister();
        }