public void HelpStrategy_Should_WriteHelpTextWithOptions() { // Arrange help data var helpData = new HelpData { CommandName = sampleCommandName, HelpTextFirstLine = { { sampleFirstLineText, string.Empty } }, Options = { { sampleOption, sampleOptionDescription } }, HelpTextLastLine = { { string.Empty, sampleLastLineText } }, LogMessage = sampleLogMessage, HelpText = sampleHelpText, }; AppioLogger.RegisterListener(_loggerListenerMock.Object); var helpStrategy = new HelpStrategy <object>(helpData); helpStrategy.CommandFactory = _factoryMock.Object; // Act var strategyResult = helpStrategy.Execute(new string[] { }); // Assert Assert.IsTrue(strategyResult.Success); Assert.IsNotNull(strategyResult.OutputMessages); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>(sampleFirstLineText, string.Empty))); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>("Options:", string.Empty))); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>(sampleOption, sampleOptionDescription))); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>(string.Empty, sampleLastLineText))); _loggerListenerMock.Verify(x => x.Info(sampleLogMessage), Times.Once); AppioLogger.RemoveListener(_loggerListenerMock.Object); }
public void HelpStrategy_Should_WriteSparseHelpTextIfNoCommandFactoryIsProvided() { // Arrange var helpData = new HelpData { CommandName = "any-name", HelpTextFirstLine = { { "any-text", "" } }, HelpTextLastLine = { { "", "any-other-text" } }, LogMessage = "any-message", HelpText = "any-text", }; var helpStrategy = new HelpStrategy <object>(helpData); // Act var strategyResult = helpStrategy.Execute(new string[] { }); // Assert Assert.IsTrue(strategyResult.Success); Assert.IsNotNull(strategyResult.OutputMessages); Assert.AreEqual(string.Empty, strategyResult.OutputMessages.First().Value); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>("any-text", string.Empty))); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>(string.Empty, "any-other-text"))); }