コード例 #1
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);
        }