Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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");
        }
Esempio n. 3
0
        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);
        }