public void NoParameters() { ITaskRegistry registry = Substitute.For<ITaskRegistry>(); UnknownTask task = new UnknownTask(registry, "GeneralHelp"); ITaskInteraction interaction = Substitute.For<ITaskInteraction>(); ILoggers loggers = Substitute.For<ILoggers>(); interaction.Loggers.Returns(loggers); ILogger logger = Substitute.For<ILogger>(); loggers[LoggerType.Status].Returns(logger); task.Execute(interaction).Should().Be(ExitCode.InvalidArgument); logger.Received().WriteLine(WriteStyle.Error, XTaskStrings.ErrorNoParametersSpecified); }
public void UnknownTaskLogsHelp() { ITaskRegistry registry = Substitute.For<ITaskRegistry>(); UnknownTask task = new UnknownTask(registry, "GeneralHelp"); ITaskInteraction interaction = Substitute.For<ITaskInteraction>(); ILoggers loggers = Substitute.For<ILoggers>(); interaction.Loggers.Returns(loggers); ILogger logger = Substitute.For<ILogger>(); loggers[LoggerType.Result].Returns(logger); task.Execute(interaction).Should().Be(ExitCode.InvalidArgument); logger.Received().WriteLine(WriteStyle.Fixed, "GeneralHelp"); }
public void UnkownCommand() { ITaskRegistry registry = Substitute.For<ITaskRegistry>(); UnknownTask task = new UnknownTask(registry, "GeneralHelp"); ITaskInteraction interaction = Substitute.For<ITaskInteraction>(); IArgumentProvider arguments = Substitute.For<IArgumentProvider>(); string commandName = "Foo"; interaction.Arguments.Returns(arguments); interaction.Arguments.Command.Returns(commandName); ILoggers loggers = Substitute.For<ILoggers>(); interaction.Loggers.Returns(loggers); ILogger logger = Substitute.For<ILogger>(); loggers[LoggerType.Status].Returns(logger); task.Execute(interaction).Should().Be(ExitCode.InvalidArgument); logger.Received().WriteLine(WriteStyle.Error, XTaskStrings.UnknownCommand, commandName); }