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