~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to samples/Gallio/Gallio.Extension/SharpDevelopTagFormatter.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// <file>
 
2
//     <copyright see="prj:///doc/copyright.txt"/>
 
3
//     <license see="prj:///doc/license.txt"/>
 
4
//     <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
 
5
//     <version>$Revision$</version>
 
6
// </file>
 
7
 
 
8
using System;
 
9
using System.Text;
 
10
using Gallio.Common.Markup;
 
11
using Gallio.Common.Markup.Tags;
 
12
using Gallio.Runner.Reports.Schema;
 
13
 
 
14
namespace Gallio.Extension
 
15
{
 
16
        public class SharpDevelopTagFormatter : ITagVisitor
 
17
        {
 
18
                StringBuilder textBuilder = new StringBuilder();
 
19
                string testResultMessage = String.Empty;
 
20
                
 
21
                public void Visit(TestStepRun testStepRun)
 
22
                {
 
23
                        foreach (StructuredStream stream in testStepRun.TestLog.Streams) {
 
24
                                VisitBodyTag(stream.Body);
 
25
                        }
 
26
                }
 
27
                
 
28
                public void VisitBodyTag(BodyTag tag)
 
29
                {
 
30
                        foreach (Tag childTag in tag.Contents) {
 
31
                                childTag.Accept(this);
 
32
                        }
 
33
                }
 
34
                
 
35
                public void VisitSectionTag(SectionTag tag)
 
36
                {
 
37
                        textBuilder.Append(tag.Name + " ");
 
38
                        tag.AcceptContents(this);
 
39
                }
 
40
                
 
41
                public void VisitMarkerTag(MarkerTag tag)
 
42
                {
 
43
                        if (tag.Class == Marker.StackTraceClass) {
 
44
                                testResultMessage = textBuilder.ToString();
 
45
                                textBuilder = new StringBuilder();
 
46
                        }
 
47
                        tag.AcceptContents(this);
 
48
                }
 
49
                
 
50
                public void VisitEmbedTag(EmbedTag tag)
 
51
                {
 
52
                }
 
53
                
 
54
                public void VisitTextTag(TextTag tag)
 
55
                {
 
56
                        textBuilder.Append(tag.Text);
 
57
                }
 
58
                
 
59
                public string TestResultMessage {
 
60
                        get { return testResultMessage; }
 
61
                }
 
62
                
 
63
                public string GetStackTrace()
 
64
                {
 
65
                        return textBuilder.ToString();
 
66
                }
 
67
        }
 
68
}