blob: 84a7b4876a656834b4cf15a0e37e9a224774c103 (
plain)
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
93
94
95
96
97
98
|
//
// MonoTests.System.Diagnostics.StackTraceTest.cs
//
// Author:
// Alexander Klyubin (klyubin@aqris.com)
//
// (C) 2001
//
using System;
using System.Diagnostics;
using System.Reflection;
using NUnit.Framework;
namespace MonoTests.System.Diagnostics {
public class StackTraceTest {
private StackTraceTest() {}
public static ITest Suite
{
get
{
TestSuite suite = new TestSuite();
suite.AddTest(StackTraceTest1.Suite);
return suite;
}
}
/// <summary>
/// Tests the case where StackTrace is created for specified
/// stack frame.
/// </summary>
private class StackTraceTest1 : TestCase {
public StackTraceTest1(string name) : base(name) {}
private StackTrace trace;
private StackFrame frame;
internal static ITest Suite
{
get
{
return new TestSuite(typeof(StackTraceTest1));
}
}
protected override void SetUp() {
frame = new StackFrame("dir/someFile",
13,
45);
trace = new StackTrace(frame);
}
protected override void TearDown() {
trace = null;
}
/// <summary>
/// Tests whether getting number of frames works.
/// </summary>
public void TestFrameCount() {
AssertEquals("Frame count",
1,
trace.FrameCount);
}
/// <summary>
/// Tests whether getting frames by index which is out of
/// range works.
/// </summary>
public void TestGetFrameOutOfRange() {
Assert("Frame with index -1 == null",
(trace.GetFrame(-1) == null));
Assert("Frame with index -129 = null",
(trace.GetFrame(-129) == null));
Assert("Frame with index 1 = null",
(trace.GetFrame(1) == null));
Assert("Frame with index 145 = null",
(trace.GetFrame(145) == null));
}
/// <summary>
/// Tests whether getting frames by index works.
/// </summary>
public void TestGetFrame() {
AssertEquals("Frame with index 0",
frame,
trace.GetFrame(0));
}
}
}
}
|