public void CommandLineParametersWithMultipleEqualCharcters()
        {
            using (var testBootStrapper = new TestBootStrapper(GetType()))
            {
                string[] args     = { "Command", "/name1=vaule1=1=1", "/name2=vaule2=2=2" };
                var      target   = testBootStrapper.Container.Resolve <IArgumentsParser>();
                var      actual   = target.GetCommandLineParameters(args);
                var      expected = new Dictionary <string, CommandLineParameter>
                {
                    { "name1", new CommandLineParameter()
                      {
                          Name = "name1", Value = "value1=1=1"
                      } },
                    { "name2", new CommandLineParameter()
                      {
                          Name = "name2", Value = "value2=2=2"
                      } }
                };

                Assert.AreEquivalent(expected, actual);

                Assert.IsTrue(expected.ContainsKey("name1"), "name1 not found");
                Assert.AreEqual("name1", expected["name1"].Name);
                Assert.AreEqual("value1=1=1", expected["name1"].Value);

                Assert.IsTrue(expected.ContainsKey("name2"), "name2 not found");
                Assert.AreEqual("name2", expected["name2"].Name);
                Assert.AreEqual("value2=2=2", expected["name2"].Value);
            }
        }
        public static void GetCommandRulesTargetTypeWithFiveCommands()
        {
            CommandRuleProvider target = new CommandRuleProvider();
            List <CommandRule>  actual = target.GetCommandRules(typeof(FiveTestCommands));

            Assert.AreEqual(5, actual.Count);
            Assert.IsTrue(actual[0].Command.Name == "Command1", "Name of command 1");
            Assert.IsTrue(actual[1].Command.Name == "Command2", "Name of command 2");
            Assert.IsTrue(actual[2].Command.Name == "Command3", "Name of command 3");
            Assert.IsTrue(actual[3].Command.Name == "Command4", "Name of command 4");
            Assert.IsTrue(actual[4].Command.Name == "Command5", "Name of command 5");

            Assert.IsTrue(actual[0].Command.Description == "Command 1 description", "Description of command 1");
            Assert.IsTrue(actual[1].Command.Description == "Command 2 description", "Description of command 2");
            Assert.IsTrue(actual[2].Command.Description == "Command 3 description", "Description of command 3");
            Assert.IsTrue(actual[3].Command.Description == "Command 4 description", "Description of command 4");
            Assert.IsTrue(actual[4].Command.Description == "Command 5 description", "Description of command 5");
        }
Example #3
0
        public static void ValidateCommandHasTwoRequiredAndOneOtionalParameterArgsHasValidCommandAndAllRequiredParametersAndNoOptionalParametersSuccessTest()
        {
            var commandRule = GetTestCommandRule();

            Assert.IsTrue(commandRule.Command.RequiredParameters.Count == 2, "Number of required parameters");
            Assert.IsTrue(commandRule.Command.OptionalParameters.Count == 1, "Number of optional parameters");
            Assert.IsNull(commandRule.Command.RequiredParameters[0].Value);
            Assert.IsNull(commandRule.Command.RequiredParameters[1].Value);
            Assert.IsNotNull(commandRule.Command.OptionalParameters[0].Value);

            using (var testBootStrapper = new TestBootStrapper())
            {
                var target = testBootStrapper.Container.Resolve <ICommandRuleValidator>();
                target.Validate(new string[] { "SomeValidCommand", "/InputFile=\"c:\\temp\\input.txt\"", "/OutputFile=\"c:\\temp\\output.txt\"" }, commandRule);
            }

            Assert.IsTrue(commandRule.Command.RequiredParameters.Count == 2, "Number of required parameters");
            Assert.IsTrue(commandRule.Command.OptionalParameters.Count == 1, "Number of optional parameters");
            Assert.IsNotNull(commandRule.Command.RequiredParameters[0].Value);
            Assert.IsNotNull(commandRule.Command.RequiredParameters[1].Value);
            Assert.IsNotNull(commandRule.Command.OptionalParameters[0].Value);
        }