public StreamState(string streamName) { stream = new StructuredStream(streamName); containerStack = new Stack <ContainerTag>(); textBuilder = new StringBuilder(); containerStack.Push(stream.Body); }
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")); }
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); }
/// <summary> /// Formats the document to a string by concatenating all formatted streams and /// displaying a "*** Stream Name ***" header for each stream name. /// </summary> /// <returns>The formatted text.</returns> public override string ToString() { StringBuilder builder = new StringBuilder(); for (int i = 0; i < streams.Count; i++) { if (i != 0) { builder.Append('\n'); } StructuredStream stream = streams[i]; builder.Append("*** ").Append(stream.Name).Append(" ***").Append("\n\n"); string contents = stream.ToString(); builder.Append(contents); if (!contents.EndsWith("\n")) { builder.Append('\n'); } } return(builder.ToString()); }
public StreamState(string streamName) { stream = new StructuredStream(streamName); containerStack = new Stack<ContainerTag>(); textBuilder = new StringBuilder(); containerStack.Push(stream.Body); }
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); }
public void NameCanBeSetToNonNull() { StructuredStream stream = new StructuredStream("name"); stream.Name = "foo"; Assert.AreEqual("foo", stream.Name); }
public void ConstructorCreatesAnEmptyStream() { StructuredStream stream = new StructuredStream("name"); Assert.AreEqual("name", stream.Name); Assert.IsEmpty(stream.Body.Contents); }
public void ToStringPrintsTheBody() { StructuredStream stream = new StructuredStream("name") { Body = new BodyTag() { Contents = { new TextTag("text") } } }; Assert.AreEqual("text", stream.ToString()); }
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 }
private void CaptureExceptions(StructuredStream stream) { stream.Body.Accept(exceptionVisitor); }
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; } }