Example #1
0
        public void cannot_place_turtle_if_its_already_placed_on_table()
        {
            var consoleRunner = new ConsoleRunner();

            consoleRunner.Execute("PLace 1,2,EAST", null);

            Assert.Throws <InvalidOperationException>(() => consoleRunner.Execute("PLace 1,2,EAST", null));
        }
Example #2
0
        public void can_place_turtle_on_the_table()
        {
            var consoleRunner = new ConsoleRunner();

            var reportedValue = string.Empty;

            consoleRunner.Execute("PLace 1,2,EAST", (textToOutput) => { reportedValue = textToOutput; });
            consoleRunner.Execute("Report", (textToOutput) => { reportedValue = textToOutput; });

            Assert.Equal("1, 2, EAST", reportedValue);
        }
Example #3
0
        public void can_turtle_move_on_the_table_if_commands_are_valid(string placeCommand, string subSequencialCommand, string expectedReportedValue)
        {
            var consoleRunner = new ConsoleRunner();

            var actualReportedValue = string.Empty;

            consoleRunner.Execute(placeCommand, (textToOutput) => { actualReportedValue = textToOutput; });
            consoleRunner.Execute(subSequencialCommand, (textToOutput) => { actualReportedValue = textToOutput; });
            consoleRunner.Execute("Report", (textToOutput) => { actualReportedValue = textToOutput; });

            Assert.Equal(expectedReportedValue, actualReportedValue);
        }
Example #4
0
        public void ThrowsNUnitEngineExceptionWhenTestResultsAreNotWriteable()
        {
            var testEngine = new TestEngine();

            testEngine.Services.Add(new FakeResultService());

            var consoleRunner = new ConsoleRunner(testEngine, new ConsoleOptions("mock-assembly.dll"), new ColorConsoleWriter());

            var ex = Assert.Throws <NUnitEngineException>(() => { consoleRunner.Execute(); });

            Assert.That(ex.Message, Is.EqualTo("The path specified in --result TestResult.xml could not be written to"));
        }
Example #5
0
        public void CommandWillReturnOutputAsString()
        {
            var command = new ConsoleCommand
            {
                CommandFullLocation = "CommandLineUnitTester"
            };

            var runner = new ConsoleRunner(command);

            runner.Execute();

            Assert.That(runner.Output.Contains("This is echo base."), Is.True);
        }
Example #6
0
        public void ThrowsNUnitEngineExceptionWhenTestResultsAreNotWriteable()
        {
            using (var testEngine = new TestEngine())
            {
                testEngine.Services.Add(new FakeResultService());
                testEngine.Services.Add(new TestFilterService());
                testEngine.Services.Add(Substitute.For <IService, IExtensionService>());

                var consoleRunner = new ConsoleRunner(testEngine, ConsoleMocks.Options("mock-assembly.dll"), new ColorConsoleWriter());

                var ex = Assert.Throws <NUnitEngineException>(() => { consoleRunner.Execute(); });
                Assert.That(ex, Has.Message.EqualTo("The path specified in --result TestResult.xml could not be written to"));
            }
        }
Example #7
0
        public void CommandRunnerWillHaveErrorOutput()
        {
            var command = new ConsoleCommand
            {
                CommandFullLocation = "CommandLineUnitTester",
                Arguments           = "We read you red 5"
            };

            var runner = new ConsoleRunner(command);

            runner.Execute();

            Assert.That(runner.ErrorOutput.Contains("This is on the Error Stream"));
        }
Example #8
0
        public void CommandWithArguments()
        {
            var command = new ConsoleCommand
            {
                CommandFullLocation = "CommandLineUnitTester",
                Arguments           = "We read you red 5",
            };

            var runner = new ConsoleRunner(command);

            runner.Execute();

            Assert.That(runner.Output.Contains("Wereadyoured5"), Is.True);
        }
Example #9
0
        public void CommandWillRunInGivenDirectory()
        {
            var command = new ConsoleCommand
            {
                CommandFullLocation = "CommandLineUnitTester",
                Arguments           = "We read you red 5",
                WorkingDirectory    = @"C:\Program Files"
            };

            var runner = new ConsoleRunner(command);

            runner.Execute();

            Assert.That(runner.Output.Contains(@"C:\Program Files"), Is.True);
        }
        public void ThrowsNUnitEngineExceptionWhenTestResultsAreNotWriteable()
        {
            var testEngine = new TestEngine();

            // This worked when we only needed one service. We now
            // would need to create three fakes. We should find a
            // better way to test this. Since it's a relatively
            // minor test, I'm leaving it for the future.
            testEngine.Services.Add(new FakeResultService());

            var consoleRunner = new ConsoleRunner(testEngine, new ConsoleOptions("mock-assembly.dll"), new ColorConsoleWriter());

            var ex = Assert.Throws <NUnitEngineException>(() => { consoleRunner.Execute(); });

            Assert.That(ex.Message, Is.EqualTo("The path specified in --result TestResult.xml could not be written to"));
        }
Example #11
0
        public void CommandLineRunnerWillTriggerEventWhenOutputRecieved()
        {
            var command = new ConsoleCommand
            {
                CommandFullLocation = "CommandLineUnitTester"
            };

            var runner = new ConsoleRunner(command);

            var dataCollection = new List <string>();

            runner.StandardOutputReceived += e => dataCollection.Add(e.Data);

            runner.Execute();

            Assert.That(dataCollection.Contains("This is echo base."));
        }
        public WfResult Run(CancellationToken token)
        {
            WfResult result = WfResult.Unknown;

            //_logger.Write(String.Format("SqlServer: {0} query: {1}", _attributes[CONNECTION_STRING], _attributes[QUERY_STRING]));

            using (ConsoleRunner p = new ConsoleRunner())
            {
                p.Timeout     = Int32.Parse(_attributes[TIMEOUT]);
                p.haveOutput += delegate(object sender, HaveOutputEventArgs e)
                {
                    _logger.Debug(e.Output);
                };

                using (token.Register(p.Dispose))
                {
                    int ret = p.Execute(_attributes[APP_NAME], _attributes[APP_ARGS]);
                    result = (ret == 0) ? WfResult.Succeeded : WfResult.Failed;
                }
            }

            return(result);
        }
Example #13
0
 // ----------------------------------------------------------------------
 static void Main(string[] args)
 {
     ConsoleRunner.Execute(typeof(Program).Assembly, args);
 } // Main