~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Analysis/UnitTesting/Src/TestResult.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
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using ICSharpCode.SharpDevelop.Dom;
 
6
 
 
7
namespace ICSharpCode.UnitTesting
 
8
{
 
9
        public enum TestResultType {
 
10
                /// <summary>
 
11
                /// The test has not been run.
 
12
                /// </summary>
 
13
                None    = 0,
 
14
                
 
15
                /// <summary>
 
16
                /// The test passed.
 
17
                /// </summary>
 
18
                Success = 1,
 
19
                
 
20
                /// <summary>
 
21
                /// The test failed.
 
22
                /// </summary>
 
23
                Failure = 2,
 
24
                
 
25
                /// <summary>
 
26
                /// The test was ignored.
 
27
                /// </summary>
 
28
                Ignored = 3
 
29
        }
 
30
        
 
31
        /// <summary>
 
32
        /// Holds the information about a single test result.
 
33
        /// </summary>
 
34
        public class TestResult
 
35
        {
 
36
                string name = String.Empty;
 
37
                string message = String.Empty;
 
38
                string stackTrace = String.Empty;
 
39
                TestResultType resultType = TestResultType.None;
 
40
                FilePosition stackTraceFilePosition = FilePosition.Empty;
 
41
                
 
42
                public TestResult(string name)
 
43
                {
 
44
                        this.name = name;
 
45
                }
 
46
                
 
47
                public string Name {
 
48
                        get { return name; }
 
49
                }
 
50
                
 
51
                public bool IsSuccess {
 
52
                        get { return resultType == TestResultType.Success; }
 
53
                }
 
54
                
 
55
                public bool IsFailure {
 
56
                        get { return resultType == TestResultType.Failure; }
 
57
                }
 
58
                
 
59
                public bool IsIgnored {
 
60
                        get { return resultType == TestResultType.Ignored; }
 
61
                }
 
62
                
 
63
                public TestResultType ResultType {
 
64
                        get { return resultType; }
 
65
                        set { resultType = value; }
 
66
                }
 
67
                
 
68
                public string Message {
 
69
                        get { return message; }
 
70
                        set { message = value; }
 
71
                }
 
72
                
 
73
                public string StackTrace {
 
74
                        get { return stackTrace; }
 
75
                        set {
 
76
                                if (stackTrace != value) {
 
77
                                        stackTrace = value;
 
78
                                        OnStackTraceChanged();
 
79
                                }
 
80
                        }
 
81
                }
 
82
                
 
83
                protected virtual void OnStackTraceChanged()
 
84
                {
 
85
                }
 
86
                
 
87
                public FilePosition StackTraceFilePosition {
 
88
                        get { return stackTraceFilePosition; }
 
89
                        set { stackTraceFilePosition = value; }
 
90
                }
 
91
        }
 
92
}