コード例 #1
0
            public StreamState(string streamName)
            {
                stream         = new StructuredStream(streamName);
                containerStack = new Stack <ContainerTag>();
                textBuilder    = new StringBuilder();

                containerStack.Push(stream.Body);
            }
コード例 #2
0
        public void BodyCanBeSetToNonNull()
        {
            BodyTag newBody = new BodyTag();

            StructuredStream stream = new StructuredStream("name");
            stream.Body = newBody;
            Assert.AreSame(newBody, stream.Body);
        }
コード例 #3
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"));
        }
		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);
		}
コード例 #5
0
        /// <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());
        }
コード例 #6
0
            public StreamState(string streamName)
            {
                stream = new StructuredStream(streamName);
                containerStack = new Stack<ContainerTag>();
                textBuilder = new StringBuilder();

                containerStack.Push(stream.Body);
            }
コード例 #7
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());
        }
コード例 #8
0
 public void WriteToThrowsIfWriterIsNull()
 {
     StructuredStream stream = new StructuredStream("name");
     Assert.Throws<ArgumentNullException>(() => stream.WriteTo(null));
 }
コード例 #9
0
 public void BodyCannotBeSetToNull()
 {
     StructuredStream stream = new StructuredStream("name");
     Assert.Throws<ArgumentNullException>(() => stream.Body = null);
 }
コード例 #10
0
 public void NameCanBeSetToNonNull()
 {
     StructuredStream stream = new StructuredStream("name");
     stream.Name = "foo";
     Assert.AreEqual("foo", stream.Name);
 }
コード例 #11
0
 public void ConstructorCreatesAnEmptyStream()
 {
     StructuredStream stream = new StructuredStream("name");
     Assert.AreEqual("name", stream.Name);
     Assert.IsEmpty(stream.Body.Contents);
 }
コード例 #12
0
        public void ToStringPrintsTheBody()
        {
            StructuredStream stream = new StructuredStream("name")
            {
                Body = new BodyTag()
                {
                    Contents =
                    {
                        new TextTag("text")
                    }
                }
            };

            Assert.AreEqual("text", stream.ToString());
        }
コード例 #13
0
        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
        }
コード例 #14
0
 private void CaptureExceptions(StructuredStream stream)
 {
     stream.Body.Accept(exceptionVisitor);
 }
コード例 #15
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;
                }
            }