public void ConstructorCreatesAnEmptyStream() { StructuredStream stream = new StructuredStream("name"); Assert.AreEqual("name", stream.Name); Assert.IsEmpty(stream.Body.Contents); }
public void NameCanBeSetToNonNull() { StructuredStream stream = new StructuredStream("name"); stream.Name = "foo"; Assert.AreEqual("foo", stream.Name); }
public StructuredStream CreateAssertionFailureStructuredStream() { StructuredStream stream = new StructuredStream("Failures"); stream.Body = CreateAssertionFailure(); return(stream); }
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; } }
public void BodyCanBeSetToNonNull() { BodyTag newBody = new BodyTag(); StructuredStream stream = new StructuredStream("name"); stream.Body = newBody; Assert.AreSame(newBody, stream.Body); }
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")); }
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); }
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); }
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 }
public void ToStringPrintsTheBody() { StructuredStream stream = new StructuredStream("name") { Body = new BodyTag() { Contents = { new TextTag("text") } } }; Assert.AreEqual("text", stream.ToString()); }
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); }
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); }
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()); }
public void WriteToThrowsIfWriterIsNull() { StructuredStream stream = new StructuredStream("name"); Assert.Throws <ArgumentNullException>(() => stream.WriteTo(null)); }
public void BodyCannotBeSetToNull() { StructuredStream stream = new StructuredStream("name"); Assert.Throws <ArgumentNullException>(() => stream.Body = null); }
/// <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()); }
private void CaptureExceptions(StructuredStream stream) { stream.Body.Accept(exceptionVisitor); }
private static string FormatStream(TestStepRun testStepRun, string streamName) { StructuredStream stream = testStepRun.TestLog.GetStream(streamName); return(stream != null?stream.ToString() : @""); }