public static void GetCommandRulesHelpProviderTest() { var target = new CommandRuleProvider(); var actualCommandRules = target.GetCommandRules(typeof(TestCommands9)); var messenger = new StringMessenger(); var helpProvider = new HelpProvider(new Func <IMessenger>(() => messenger)); helpProvider.ShowHelp(actualCommandRules, null, new ApplicationInfo()); Assert.Contains("CommandWithBothDescriptionAndSummaryDefined Summary of command", messenger.Message.ToString()); Assert.Contains("CommandWithOnlyDescriptionAndNoSummaryDefined Command with only", messenger.Message.ToString()); Assert.Contains("CommandWithTwoRequiredParameterAndOneOptionalParameter Summary of", messenger.Message.ToString()); Assert.Contains("CommandWithBothDescriptionAndSummaryDefined Command with both", messenger.Message.ToString()); Assert.Contains("CommandWithOnlyDescriptionAndNoSummaryDefined Command with only", messenger.Message.ToString()); Assert.Contains("CommandWithTwoRequiredParameterAndOneOptionalParameter Command with two", messenger.Message.ToString()); }
public static void RunCommandWithNoParametersThrowingExceptionCheckStackTrace() { var testLoggerMoc = new Mock <ITestLogger>(); TestCommands1.TestLogger = testLoggerMoc.Object; const string logMessage = "Running CommandWithNoParametersThrowingException"; testLoggerMoc.Setup(logger => logger.Write(logMessage)); try { CmdLinery.Run(typeof(TestCommands1), new string[] { "CommandWithNoParametersThrowingException" }, new TestApplicationInfo()); } catch (Exception ex) { Assert.Contains("TestCommands1.CommandWithNoParametersThrowingException", ex.StackTrace); } testLoggerMoc.Verify(logger => logger.Write(logMessage), Times.Once); }