private void AssertBounceCommand(Action <RemoteBounceArguments, IBounce> commandAction, string command)
        {
            var bounce = new FakeBounce();

            bounce.ParametersGiven = new[] { new Parameter <string>("name", "value") };

            var a = new Mock <IObsoleteTask>().Object;
            var b = new Mock <IObsoleteTask>().Object;
            var overridingParameters = new[] { new Mock <IParameter>().Object };

            var logOptionTranslator = new Mock <ILogOptionCommandLineTranslator>();

            logOptionTranslator.Setup(l => l.GenerateCommandLine(bounce)).Returns("logoptions");

            var commandLineParametersGenerator = new Mock <ICommandLineTasksParametersGenerator>();

            commandLineParametersGenerator.Setup(c => c.GenerateCommandLineParametersForTasks(bounce.ParametersGiven, overridingParameters)).Returns("build_arguments_and_params");

            var remoteBounce = new RemoteBounceArguments(new TargetsParser(), logOptionTranslator.Object, commandLineParametersGenerator.Object);

            remoteBounce.Targets    = new [] { "Junk" };
            remoteBounce.Parameters = overridingParameters;

            commandAction(remoteBounce, bounce);
            Assert.That(remoteBounce.Value, Is.EqualTo("logoptions " + command + " Junk build_arguments_and_params"));
        }
示例#2
0
        private void AssertThatParameterSetsOption(string parameterName, string parameterValue, Func <IBounce, object> option, object expectedValue)
        {
            var parameters = new ParsedCommandLineParameters();

            parameters.Parameters.Add(new ParsedCommandLineParameter {
                Name = parameterName, Value = parameterValue
            });

            var bounce = new FakeBounce();

            new LogOptionCommandLineTranslator(LogFactoryRegistry).ParseCommandLine(parameters, bounce);

            Func <IBounce, object> commandOutput = option;

            Assert.That(commandOutput(bounce), Is.EqualTo(expectedValue));
        }
        public void ShouldGenerateCommandLineParametersFromOptionsWithoutLogFormatWhenNotFound()
        {
            ITaskLogFactory myLogger = new Mock<ITaskLogFactory>().Object;

            var translator = new LogOptionCommandLineTranslator(LogFactoryRegistry);

            var bounce = new FakeBounce();

            bounce.LogFactory = myLogger;
            bounce.LogOptions.DescribeTasks = true;
            bounce.LogOptions.CommandOutput = false;
            bounce.LogOptions.LogLevel = LogLevel.Warning;

            var commandLine = translator.GenerateCommandLine(bounce);

            Assert.That(commandLine, ContainsArgument("/describe-tasks:true"));
            Assert.That(commandLine, ContainsArgument("/loglevel:warning"));
            Assert.That(commandLine, ContainsArgument("/command-output:false"));
            Assert.That(commandLine, Is.Not.StringMatching(@"(^|\s)/logformat:"));
        }
示例#4
0
        public void ShouldGenerateCommandLineParametersFromOptionsWithoutLogFormatWhenNotFound()
        {
            ITaskLogFactory myLogger = new Mock <ITaskLogFactory>().Object;

            var translator = new LogOptionCommandLineTranslator(LogFactoryRegistry);

            var bounce = new FakeBounce();

            bounce.LogFactory = myLogger;
            bounce.LogOptions.DescribeTasks = true;
            bounce.LogOptions.CommandOutput = false;
            bounce.LogOptions.LogLevel      = LogLevel.Warning;

            var commandLine = translator.GenerateCommandLine(bounce);

            Assert.That(commandLine, ContainsArgument("/describe-tasks:true"));
            Assert.That(commandLine, ContainsArgument("/loglevel:warning"));
            Assert.That(commandLine, ContainsArgument("/command-output:false"));
            Assert.That(commandLine, Is.Not.StringMatching(@"(^|\s)/logformat:"));
        }
        public void ShouldGenerateCommandLineParametersFromOptions()
        {
            ITaskLogFactory myLogger = new Mock<ITaskLogFactory>().Object;
            LogFactoryRegistry.RegisterLogFactory("mylogger", myLogger);

            var translator = new LogOptionCommandLineTranslator(LogFactoryRegistry);

            var bounce = new FakeBounce();

            bounce.LogFactory = myLogger;
            bounce.LogOptions.DescribeTasks = true;
            bounce.LogOptions.CommandOutput = false;
            bounce.LogOptions.LogLevel = LogLevel.Warning;

            var commandLine = translator.GenerateCommandLine(bounce);

            Assert.That(commandLine, ContainsArgument("/describe-tasks:true"));
            Assert.That(commandLine, ContainsArgument("/loglevel:warning"));
            Assert.That(commandLine, ContainsArgument("/command-output:false"));
            Assert.That(commandLine, ContainsArgument("/logformat:mylogger"));
        }
        private void AssertBounceCommand(Action<RemoteBounceArguments, IBounce> commandAction, string command)
        {
            var bounce = new FakeBounce();
            bounce.ParametersGiven = new[] {new Parameter<string>("name", "value")};

            var a = new Mock<IObsoleteTask>().Object;
            var b = new Mock<IObsoleteTask>().Object;
            var overridingParameters = new[] {new Mock<IParameter>().Object};

            var logOptionTranslator = new Mock<ILogOptionCommandLineTranslator>();
            logOptionTranslator.Setup(l => l.GenerateCommandLine(bounce)).Returns("logoptions");

            var commandLineParametersGenerator = new Mock<ICommandLineTasksParametersGenerator>();
            commandLineParametersGenerator.Setup(c => c.GenerateCommandLineParametersForTasks(bounce.ParametersGiven, overridingParameters)).Returns("build_arguments_and_params");

            var remoteBounce = new RemoteBounceArguments(new TargetsParser(), logOptionTranslator.Object, commandLineParametersGenerator.Object);
            remoteBounce.Targets = new [] {"Junk"};
            remoteBounce.Parameters = overridingParameters;

            commandAction(remoteBounce, bounce);
            Assert.That(remoteBounce.Value, Is.EqualTo("logoptions " + command + " Junk build_arguments_and_params"));
        }
示例#7
0
        public void ShouldGenerateCommandLineParametersFromOptions()
        {
            ITaskLogFactory myLogger = new Mock <ITaskLogFactory>().Object;

            LogFactoryRegistry.RegisterLogFactory("mylogger", myLogger);

            var translator = new LogOptionCommandLineTranslator(LogFactoryRegistry);

            var bounce = new FakeBounce();

            bounce.LogFactory = myLogger;
            bounce.LogOptions.DescribeTasks = true;
            bounce.LogOptions.CommandOutput = false;
            bounce.LogOptions.LogLevel      = LogLevel.Warning;

            var commandLine = translator.GenerateCommandLine(bounce);

            Assert.That(commandLine, ContainsArgument("/describe-tasks:true"));
            Assert.That(commandLine, ContainsArgument("/loglevel:warning"));
            Assert.That(commandLine, ContainsArgument("/command-output:false"));
            Assert.That(commandLine, ContainsArgument("/logformat:mylogger"));
        }
        private void AssertThatParameterSetsOption(string parameterName, string parameterValue, Func<IBounce, object> option, object expectedValue)
        {
            var parameters = new ParsedCommandLineParameters();
            parameters.Parameters.Add(new ParsedCommandLineParameter {Name = parameterName, Value = parameterValue});

            var bounce = new FakeBounce();

            new LogOptionCommandLineTranslator(LogFactoryRegistry).ParseCommandLine(parameters, bounce);

            Func<IBounce, object> commandOutput = option;
            Assert.That(commandOutput(bounce), Is.EqualTo(expectedValue));
        }