コード例 #1
0
        public void ConstructorCreatesAnEmptyStream()
        {
            StructuredStream stream = new StructuredStream("name");

            Assert.AreEqual("name", stream.Name);
            Assert.IsEmpty(stream.Body.Contents);
        }
コード例 #2
0
        public void NameCanBeSetToNonNull()
        {
            StructuredStream stream = new StructuredStream("name");

            stream.Name = "foo";
            Assert.AreEqual("foo", stream.Name);
        }
コード例 #3
0
        public StructuredStream CreateAssertionFailureStructuredStream()
        {
            StructuredStream stream = new StructuredStream("Failures");

            stream.Body = CreateAssertionFailure();
            return(stream);
        }
コード例 #4
0
            private void OutputLogStreamContents(StructuredStream stream)
            {
                string contents = string.Concat("*** ", stream.Name, " ***\n", stream.ToString(), "\n");

                // ReSharper formats the TaskExplain contents only when the task result is of a particular value.
                // It will render it in a colored box based on the result code.
                // Unfortunately it can't really capture the richness of Gallio outcomes right now.
                switch (stream.Name)
                {
                case MarkupStreamNames.ConsoleError:
                    Output(FacadeTaskOutputType.StandardError, contents);
                    break;

                case MarkupStreamNames.DebugTrace:
                    Output(FacadeTaskOutputType.DebugTrace, contents);
                    break;

                case MarkupStreamNames.Warnings:
                    pendingWarnings = contents;
                    break;

                case MarkupStreamNames.Failures:
                    pendingFailures = contents;
                    break;

                default:
                    Output(FacadeTaskOutputType.StandardOutput, contents);
                    break;
                }
            }
コード例 #5
0
        public void BodyCanBeSetToNonNull()
        {
            BodyTag newBody = new BodyTag();

            StructuredStream stream = new StructuredStream("name");

            stream.Body = newBody;
            Assert.AreSame(newBody, stream.Body);
        }
コード例 #6
0
        public void GetStreamReturnsNamedStream()
        {
            var log    = new StructuredDocument();
            var stream = new StructuredStream("foo");

            log.Streams.Add(stream);
            log.Streams.Add(new StructuredStream("bar"));

            Assert.AreSame(stream, log.GetStream("foo"));
        }
コード例 #7
0
        protected static void AssertLogDoesNotContain(TestStepRun run, string expectedOutput, string streamName)
        {
            if (run == null)
            {
                throw new ArgumentNullException("run");
            }

            StructuredStream stream = run.TestLog.GetStream(streamName);

            Assert.DoesNotContain((stream == null) ? String.Empty : stream.ToString(), expectedOutput);
        }
コード例 #8
0
        protected static void AssertLogLike(TestStepRun run, string expectedOutputPattern, string streamName)
        {
            if (run == null)
            {
                throw new ArgumentNullException("run");
            }

            StructuredStream stream = run.TestLog.GetStream(streamName);
            string           log    = (stream == null) ? String.Empty : stream.ToString();

            Assert.Like(log, expectedOutputPattern);
        }
コード例 #9
0
ファイル: ReportAssert.cs プロジェクト: citizenmatt/gallio
        public static void AreEqual(StructuredStream expected, StructuredStream actual)
        {
            if (expected == null)
            {
                Assert.IsNull(actual);
                return;
            }

            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.ToString(), actual.ToString());

            // FIXME: not precise
        }
コード例 #10
0
        public void ToStringPrintsTheBody()
        {
            StructuredStream stream = new StructuredStream("name")
            {
                Body = new BodyTag()
                {
                    Contents =
                    {
                        new TextTag("text")
                    }
                }
            };

            Assert.AreEqual("text", stream.ToString());
        }
コード例 #11
0
        public void Init()
        {
            GallioBodyTagFactory factory = new GallioBodyTagFactory();

            structuredStream                = factory.CreateAssertionFailureStructuredStream();
            bodyTag                         = structuredStream.Body;
            assertionFailureMarkerTag       = GetFirstChildMarkerTag(bodyTag);
            expectedValueToBeTrueSectionTag = GetFirstChildSectionTag(assertionFailureMarkerTag);
            expectedValueToBeTrueTextTag    = GetFirstChildTextTag(expectedValueToBeTrueSectionTag);
            monoSpaceMarkerTag              = GetSecondChildMarkerTag(expectedValueToBeTrueSectionTag);
            textTagAfterMonoSpaceMarkerTag  = GetThirdChildTextTag(expectedValueToBeTrueSectionTag);
            stackTraceMarkerTag             = GetFourthChildMarkerTag(expectedValueToBeTrueSectionTag);
            stackTraceTextTag               = GetFirstChildTextTag(stackTraceMarkerTag);
            codeLocationMarkerTag           = GetSecondChildMarkerTag(stackTraceMarkerTag);
            codeLocationTextTag             = GetFirstChildTextTag(codeLocationMarkerTag);
        }
コード例 #12
0
        private void LogTest(TestStepFinishedEventArgs e)
        {
            // A TestResult with State == TestState.Passed won't be displayed in the
            // output window (TD.NET just diplays "[TestName] passed" in the status bar.
            // Since that can be harder to notice, and also is lost when the following
            // test finishes, we print a message in the output window so the user can
            // progressively see if the tests are passing or failing.
            if (e.TestStepRun.Result.Outcome.Status == TestStatus.Passed)
            {
                testListener.WriteLine(String.Format(Resources.TDNetLogMonitor_TestCasePassed,
                                                     e.TestStepRun.Step.FullName), FacadeCategory.Info);
            }

            // Inform TD.NET what happened
            FacadeTestResult result = new FacadeTestResult();

            result.Name     = e.TestStepRun.Step.FullName;
            result.TimeSpan = e.TestStepRun.Result.Duration;
            // result.TestRunner = "Gallio"; // note: can crash in older versions of TD.Net with MissingFieldException

            // It's important to set the stack trace here so the user can double-click in the
            // output window to go the faulting line
            StructuredStream failureStream = e.TestStepRun.TestLog.GetStream(MarkupStreamNames.Failures);

            if (failureStream != null)
            {
                result.StackTrace = failureStream.ToString();
            }

            StructuredStream warningStream = e.TestStepRun.TestLog.GetStream(MarkupStreamNames.Warnings);

            if (warningStream != null)
            {
                result.Message = warningStream.ToString();
            }

            // TD.NET will automatically count the number of passed, ignored and failed tests
            // provided we call the TestFinished method with the right State
            result.State = GetTestState(e.TestStepRun.Result.Outcome.Status);

            testListener.TestFinished(result);
        }
コード例 #13
0
        public void WriteToReproducesTheBodyOfTheStream()
        {
            StructuredStream stream = new StructuredStream("name")
            {
                Body = new BodyTag()
                {
                    Contents =
                    {
                        new TextTag("text")
                    }
                }
            };

            StructuredTextWriter writer = new StructuredTextWriter();

            stream.WriteTo(writer);
            writer.Close();

            Assert.AreEqual(stream.ToString(), writer.ToString());
        }
コード例 #14
0
        public void WriteToThrowsIfWriterIsNull()
        {
            StructuredStream stream = new StructuredStream("name");

            Assert.Throws <ArgumentNullException>(() => stream.WriteTo(null));
        }
コード例 #15
0
        public void BodyCannotBeSetToNull()
        {
            StructuredStream stream = new StructuredStream("name");

            Assert.Throws <ArgumentNullException>(() => stream.Body = null);
        }
コード例 #16
0
        /// <summary>
        /// Returns the log of the specified test step run.
        /// </summary>
        /// <param name="run">The test step run.</param>
        /// <param name="streamName">The name of log stream.</param>
        /// <returns>The log text or an empty string.</returns>
        protected static string GetLog(TestStepRun run, string streamName)
        {
            StructuredStream stream = run.TestLog.GetStream(streamName);

            return((stream == null) ? String.Empty : stream.ToString());
        }
コード例 #17
0
 private void CaptureExceptions(StructuredStream stream)
 {
     stream.Body.Accept(exceptionVisitor);
 }
コード例 #18
0
        private static string FormatStream(TestStepRun testStepRun, string streamName)
        {
            StructuredStream stream = testStepRun.TestLog.GetStream(streamName);

            return(stream != null?stream.ToString() : @"");
        }