~nunit-core/nunitv2/2.5

« back to all changes in this revision

Viewing changes to src/NUnitFramework/core/TestCaseResult.cs

  • Committer: jnewkirk
  • Date: 2002-07-10 20:00:13 UTC
  • Revision ID: vcs-imports@canonical.com-20020710200013-j8us5mbi0usp7p02
initialĀ load

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Copyright (C) 2002. James W. Newkirk, Michael C. Two, Alexei A. Vorontsov. All Rights Reserved.
 
3
//
 
4
namespace Nunit.Core
 
5
{
 
6
        using System;
 
7
        using System.Text;
 
8
 
 
9
        /// <summary>
 
10
        /// 
 
11
        /// </summary>
 
12
        //
 
13
        [Serializable]
 
14
        public class TestCaseResult : TestResult
 
15
        {
 
16
                private TestCase testCase;
 
17
                private string testCaseName;
 
18
                private bool testExecuted;
 
19
                private string message;
 
20
                private string stackTrace;
 
21
 
 
22
                public TestCaseResult(TestCase testCase):base(testCase, testCase.FullName)
 
23
                {
 
24
                        this.testCase = testCase;
 
25
                        testExecuted = false;
 
26
                }
 
27
 
 
28
                public TestCaseResult(string testCaseString) : base(null, testCaseString)
 
29
                {
 
30
                        testCase = null;
 
31
                        testExecuted = false;
 
32
                        testCaseName = testCaseString;
 
33
                }
 
34
 
 
35
                public bool Executed
 
36
                {
 
37
                        get { return testExecuted; }
 
38
                }
 
39
 
 
40
                public void Success() 
 
41
                { 
 
42
                        testExecuted = true;
 
43
                        IsFailure = false; 
 
44
                }
 
45
 
 
46
                public override void NotRun(string reason)
 
47
                {
 
48
                        testExecuted = false;
 
49
                        message = reason;
 
50
                }
 
51
 
 
52
                public void Failure(string message, string stackTrace)
 
53
                {
 
54
                        testExecuted = true;
 
55
                        IsFailure = true;
 
56
                        this.message = message;
 
57
                        this.stackTrace = stackTrace;
 
58
                }
 
59
 
 
60
                public override string Message
 
61
                {
 
62
                        get { return message; }
 
63
                }
 
64
 
 
65
                public override string StackTrace
 
66
                {
 
67
                        get 
 
68
                        { 
 
69
                                return stackTrace;
 
70
                        }
 
71
                }
 
72
 
 
73
                public override string ToString()
 
74
                {
 
75
                        StringBuilder builder = new StringBuilder();
 
76
                        string name = testCaseName;
 
77
                        if(testCase != null)
 
78
                                name = testCase.FullName;
 
79
                        
 
80
                        builder.AppendFormat("{0} : " , name);
 
81
                        if(!IsSuccess)
 
82
                                builder.Append(message);
 
83
 
 
84
                        return builder.ToString();
 
85
                }
 
86
 
 
87
                public override void Accept(ResultVisitor visitor) 
 
88
                {
 
89
                        visitor.visit(this);
 
90
                }
 
91
        }
 
92
}