public static void RunCommandWithRequiredStringParameterNotSet() { Assert.Throws <MissingCommandParameterException>(() => { CmdLinery.Run(typeof(TestCommands1), new string[] { "CommandWithRequiredStringParameter" }, new TestApplicationInfo()); }); }
public static void GetCommandRuleMetodHasCommandWithNonAllowedDuplicateAttributesParametersThrowMissingCommandParameterAttributeExceptionUnitTest() { CommandRuleProvider target = new CommandRuleProvider(); Assert.Throws <DuplicateCommandParameterAttributeException>(() => { target.GetCommandRule(typeof(TestCommands0).GetMethodEx("CommandWithNonAllowedDuplicateAttributesParameters")); }); }
public static void GetCommandRuleMetodHasValidCommandWithOneParameterWithoutParameterAttributeThrowMissingCommandParameterAttributeExceptionUnitTest() { CommandRuleProvider target = new CommandRuleProvider(); Assert.Throws <MissingCommandParameterAttributeException>(() => { target.GetCommandRule(typeof(TestCommands0).GetMethodEx("CommandWithOneParameterWithoutParameterAttribute")); }); }
public void ParseArraySemicolonSeparationCorruptThrowInvalidArrayParseExeption() { const string arrayString = "'123';'21';'142;'5'"; IArrayParser target = new ArrayParser(); Assert.Throws <InvalidArrayParseException>(() => { var actual = target.Parse(arrayString); }); }
GetCommandRuleMetodHasCommandWithIncorrectlyOrderedParametersThrowMissingCommandParameterAttributeExceptionUnitTest () { CommandRuleProvider target = new CommandRuleProvider(); Assert.Throws <RequiredParameterFoundAfterOptionalParameterExecption>(() => { target.GetCommandRule(typeof(TestCommands0).GetMethodEx("CommandWithIncorrectlyOrderedParameters")); }); }
public static void ValidateCommandNotInitializedThrowNullReferenceExceptionTest() { using (var testBootStrapper = new TestBootStrapper()) { var target = testBootStrapper.Container.Resolve <ICommandRuleValidator>(); Assert.Throws <NullReferenceException>(() => { target.Validate(new string[] { "SomeCommand", "/SomeRequiredParameter=\"SomeRequiredValue\"" }, new CommandRule()); }); } }
public static void ValidateArgsNullThrowArgumentNullExceptionTest() { using (var testBootStrapper = new TestBootStrapper()) { var target = testBootStrapper.Container.Resolve <ICommandRuleValidator>(); Assert.Throws <ArgumentNullException>(() => { target.Validate(null, new CommandRule()); }); } }
public void InvalidCommandLineParametersThrow() { using (var testBootStrapper = new TestBootStrapper(GetType())) { string[] args = { "12;13;14;15", "12" }; var target = new ArgumentsParser(); Assert.Throws <InvalidCommandParameterFormatException>(() => { var actual = target.GetCommandLineParameters(args); }); } }
ValidateCommandHasTwoRequiredAndOneOtionalParameterArgsHasUnknownCommandThrowInvalidCommandExceptionTest() { using (var testBootStrapper = new TestBootStrapper()) { var target = testBootStrapper.Container.Resolve <ICommandRuleValidator>(); var commandRule = GetTestCommandRule(); Assert.Throws <InvalidCommandException>(() => { target.Validate(new string[] { "SomeUnknownCommand", "/SomeUnknownRequiredParameter=\"SomeRequiredValue\"" }, commandRule); }); } }
ValidateCommandHasTwoRequiredAndOneOtionalParameterArgsIsEmptyListThrowMissingCommandExceptionTest() { using (var testBootStrapper = new TestBootStrapper()) { var target = testBootStrapper.Container.Resolve <ICommandRuleValidator>(); var commandRule = GetTestCommandRule(); Assert.Throws <MissingCommandException>(() => { target.Validate(new string[] { }, commandRule); }); } }
public static void ValidateCommandHasTwoRequiredAndOneOtionalParameterArgsHasValidCommandAndMissingParameterThrowMissingCommandParameterExceptionTest() { using (var testBootStrapper = new TestBootStrapper()) { var target = testBootStrapper.Container.Resolve <ICommandRuleValidator>(); var commandRule = GetTestCommandRule(); Assert.Throws <MissingCommandParameterException>(() => { target.Validate(new string[] { "SomeValidCommand" }, commandRule); }); } }
public static void RunCommandWithNoParametersThrowingException() { var testLoggerMoc = new Mock <ITestLogger>(); TestCommands1.TestLogger = testLoggerMoc.Object; const string logMessage = "Running CommandWithNoParametersThrowingException"; testLoggerMoc.Setup(logger => logger.Write(logMessage)); Assert.Throws <NCmdLinerException>(() => { CmdLinery.Run(typeof(TestCommands1), new string[] { "CommandWithNoParametersThrowingException" }, new TestApplicationInfo()); }); testLoggerMoc.Verify(logger => logger.Write(logMessage), Times.Once); }
public static void CommandsFromMultipleNamespacesDuplicateCommandThrowDuplicateCommandException() { var testLoggerMoc = new Mock <ITestLogger>(); TestCommandsMulti2Duplicate.TestLogger = testLoggerMoc.Object; const string logMessage = "Running FirstCommand()"; var commandString = new string[] { "FirstCommand" }; testLoggerMoc.Setup(logger => logger.Write(logMessage)); Assert.Throws <DuplicateCommandException>(() => { CmdLinery.Run(new Type[] { typeof(TestCommandsMulti1Duplicate), typeof(TestCommandsMulti2Duplicate) }, commandString, new TestApplicationInfo()); }); }
public static void RunHelpCommandWithCustomHelperProvider() { var nonStaticTestCommands = new NonStaticTestCommands7(); var testLoggerMoc = new Mock <ITestLogger>(); nonStaticTestCommands.TestLogger = testLoggerMoc.Object; const string logMessage = "Running NonStaticCommand()"; var commandString = new string[] { "Help" }; testLoggerMoc.Setup(logger => logger.Write(logMessage)); Assert.Throws <CustomTestHelpProviderException>(() => { CmdLinery.Run(new object[] { nonStaticTestCommands }, commandString, new TestApplicationInfo(), new ConsoleMessenger(), new CustomTestHelpProvider()); }); }
public static void RunCommandWithNoOptionalDefaultValueThrowMissingExampleValueException() { var testLoggerMoc = new Mock <ITestLogger>(); TestCommands5.TestLogger = testLoggerMoc.Object; const string logMessage = "Running CommandWithNoOptionalDefaultValue(\"parameter 1 value\")"; var commandString = new string[] { "CommandWithNoOptionalDefaultValue", "/parameter1=\"parameter 1 value\"" }; testLoggerMoc.Setup(logger => logger.Write(logMessage)); Assert.Throws <MissingDefaultValueException>(() => { CmdLinery.Run(typeof(TestCommands5), commandString, new TestApplicationInfo()); }); }