コード例 #1
0
ファイル: CommandTest.cs プロジェクト: LupinChiu/Regulus
        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);
        }
コード例 #2
0
ファイル: CommandTest.cs プロジェクト: LupinChiu/Regulus
        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);
        }
コード例 #3
0
ファイル: CommandTest.cs プロジェクト: LupinChiu/Regulus
        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);
        }
コード例 #4
0
ファイル: CommandTest.cs プロジェクト: LupinChiu/Regulus
        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);
        }
コード例 #5
0
ファイル: CommandTest.cs プロジェクト: LupinChiu/Regulus
        public void TestCommandRegister1()
        {
            // data
            Command command = new Command();
            CommandRegister <ICallTester, int> cr = new CommandRegister <ICallTester, int>(

                command,
                (caller, arg1) => caller.Function2(arg1));
            ICallTester callTester = Substitute.For <ICallTester>();

            // test
            cr.Register(0, callTester);
            command.Run(
                "0Function2",
                new[]
            {
                "1"
            });

            // verify
            cr.Unregister(0);
        }