示例#1
0
        public void TwoTests_NestedExecution(string labels, string expected)
        {
            var test1   = Fakes.GetTestMethod(this, "MyFakeMethod");
            var result1 = new TestCaseResult(test1);

            result1.SetResult(ResultState.Failure);

            var test2   = Fakes.GetTestMethod(this, "AnotherFakeMethod");
            var result2 = new TestCaseResult(test2);

            result2.SetResult(ResultState.Success);

            var textUI = CreateTextUI(labels);

            textUI.TestStarted(test1);
            textUI.TestOutput(new TestOutput("Immediate output from first test\n", "", null, test1.FullName));
            textUI.TestStarted(test2);
            textUI.TestOutput(new TestOutput("Another immediate output from first test\n", "", null, test1.FullName));
            textUI.TestOutput(new TestOutput("Immediate output from second test\n", "", null, test2.FullName));
            result2.OutWriter.WriteLine("OUTPUT2");
            textUI.TestFinished(result2);
            result1.OutWriter.WriteLine("OUTPUT1");
            textUI.TestFinished(result1);

            Assert.That(Report, Is.EqualTo(expected));
        }
示例#2
0
        private static TestCaseResult CreateFailedResultForTestCase(ITest test, DateTime startTime,
                                                                    DateTime endTime, string message = null)
        {
            var caseResult = new TestCaseResult((TestMethod)test);
            var result     = new ResultState(TestStatus.Failed, FailureSite.Test);

            caseResult.SetResult(result, message);
            caseResult.StartTime = startTime;
            caseResult.EndTime   = endTime;
            caseResult.Duration  = endTime.Subtract(startTime).TotalSeconds;
            return(caseResult);
        }
示例#3
0
        public void SingleTest_StartAndFinish(string labels, string expected)
        {
            var test   = Fakes.GetTestMethod(this, "MyFakeMethod");
            var result = new TestCaseResult(test);

            result.SetResult(ResultState.Success);
            var textUI = CreateTextUI(labels);

            textUI.TestStarted(test);
            result.OutWriter.WriteLine("OUTPUT");
            textUI.TestFinished(result);

            Assert.That(Report, Is.EqualTo(expected));
        }
示例#4
0
        public void TestWritesSingleCharacters(string labels, string expected)
        {
            var result = new TestCaseResult(Fakes.GetTestMethod(this, "MyFakeMethod"));

            result.SetResult(ResultState.Success);

            result.OutWriter.Write(new [] { 'A', 'B', 'C' });
            result.OutWriter.Write('+');
            result.OutWriter.WriteLine("XYZ");

            CreateTextUI(labels).TestFinished(result);

            Assert.That(Report, Is.EqualTo(expected));
        }
示例#5
0
        public void SingleTest_ImmediateOutput(string labels, string expected)
        {
            var test   = Fakes.GetTestMethod(this, "MyFakeMethod");
            var result = new TestCaseResult(test);

            result.SetResult(ResultState.Success);
            var textUI = CreateTextUI(labels);

            textUI.TestStarted(test);
            textUI.TestOutput(new TestOutput("IMMEDIATE OUTPUT\n", "", null, test.FullName));
            result.OutWriter.WriteLine("NORMAL OUTPUT");
            textUI.TestFinished(result);

            Assert.That(Report, Is.EqualTo(expected));
        }
示例#6
0
        public void TestFinished(string labelsOption, TestStatus resultStatus, string resultLabel, string output, string expected)
        {
            var result = new TestCaseResult(Fakes.GetTestMethod(this, "MyFakeMethod"));

            result.SetResult(new ResultState(resultStatus, resultLabel));

            foreach (var line in output.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
            {
                result.OutWriter.WriteLine(line);
            }

            CreateTextUI(labelsOption).TestFinished(result);

            Assert.That(Report, Is.EqualTo(expected));
        }
示例#7
0
        public void TwoTests_SequentialExecution(string labels, string expected)
        {
            var test1   = Fakes.GetTestMethod(this, "MyFakeMethod");
            var result1 = new TestCaseResult(test1);

            result1.SetResult(ResultState.Failure);

            var test2   = Fakes.GetTestMethod(this, "AnotherFakeMethod");
            var result2 = new TestCaseResult(test2);

            result2.SetResult(ResultState.Success);

            var textUI = CreateTextUI(labels);

            textUI.TestStarted(test1);
            result1.OutWriter.WriteLine("OUTPUT1");
            textUI.TestFinished(result1);
            textUI.TestStarted(test2);
            result2.OutWriter.WriteLine("OUTPUT2");
            textUI.TestFinished(result2);

            Assert.That(Report, Is.EqualTo(expected));
        }