コード例 #1
0
        public void Initialize_Registers_Commands()
        {
            TestCommandModel expected = new TestCommandModel();

            commandFactory.CreateFromAssembliesCommand.Add("", expected);
            model.Initialize();

            Assert.AreEqual(expected, model.Commands.Values.Single());
        }
コード例 #2
0
        public void ParseArgs_Ignores_Extra_Args()
        {
            TestCommandModel cmd = new TestCommandModel
            {
                Parameters = new ParameterInfo[0]
            };

            object[] result = model.ParseArgs(cmd, new[] { "1" });
            Assert.AreEqual(0, result.Length);
        }
コード例 #3
0
        public void ExecuteCommand_Non_Existing_Returns_Error_Log()
        {
            TestCommandModel command = new TestCommandModel();

            bool called = false;

            command.OnInvokeCalled += x => called = true;
            commandsCollection.Commands.Add("foo", command);

            Model.ExecuteCommand("bar", new[] { "3" });

            Assert.IsFalse(called);
        }
コード例 #4
0
        public void ExecuteCommand_Invokes_Command()
        {
            TestCommandModel command = new TestCommandModel();

            object[] result = null;
            command.OnInvokeCalled += x => result = x;
            commandsCollection.Commands.Add("foo", command);

            commandParser.ParseArgsReturnValue = new object[] { 3 };

            Model.ExecuteCommand("foo", new[] { "3" });

            Assert.AreEqual(3, result[0]);
        }
コード例 #5
0
        public void RegisterRuntimeCommand_Registers_Command()
        {
            TestCommandModel expected = new TestCommandModel();

            commandFactory.CreateCommand = expected;
            model.RegisterRuntimeCommand("", default, default, default, default);