My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
using System;
using System.Collections;
using NUnit.Framework;

namespace SpecUnit
{
public delegate void MethodThatThrows();

public static class SpecificationExtensions
{
public static void ShouldBeFalse(this bool condition)
{
Assert.IsFalse(condition);
}

public static void ShouldBeTrue(this bool condition)
{
Assert.IsTrue(condition);
}

public static object ShouldEqual(this object actual, object expected)
{
Assert.AreEqual(expected, actual);
return expected;
}

public static object ShouldNotEqual(this object actual, object expected)
{
Assert.AreNotEqual(expected, actual);
return expected;
}

public static void ShouldBeNull(this object anObject)
{
Assert.IsNull(anObject);
}

public static void ShouldNotBeNull(this object anObject)
{
Assert.IsNotNull(anObject);
}

public static object ShouldBeTheSameAs(this object actual, object expected)
{
Assert.AreSame(expected, actual);
return expected;
}

public static object ShouldNotBeTheSameAs(this object actual, object expected)
{
Assert.AreNotSame(expected, actual);
return expected;
}

public static void ShouldBeOfType(this object actual, Type expected)
{
Assert.IsInstanceOfType(expected, actual);
}

public static void ShouldBe(this object actual, Type expected)
{
Assert.IsInstanceOfType(expected, actual);
}

public static void ShouldNotBeOfType(this object actual, Type expected)
{
Assert.IsNotInstanceOfType(expected, actual);
}

public static void ShouldContain(this IList actual, object expected)
{
Assert.Contains(expected, actual);
}

public static void ShouldNotContain(this IList collection, object expected)
{
CollectionAssert.DoesNotContain(collection, expected);
}

public static IComparable ShouldBeGreaterThan(this IComparable arg1, IComparable arg2)
{
Assert.Greater(arg1, arg2);
return arg2;
}

public static IComparable ShouldBeLessThan(this IComparable arg1, IComparable arg2)
{
Assert.Less(arg1, arg2);
return arg2;
}

public static void ShouldBeEmpty(this ICollection collection)
{
Assert.IsEmpty(collection);
}

public static void ShouldBeEmpty(this string aString)
{
Assert.IsEmpty(aString);
}

public static void ShouldNotBeEmpty(this ICollection collection)
{
Assert.IsNotEmpty(collection);
}

public static void ShouldNotBeEmpty(this string aString)
{
Assert.IsNotEmpty(aString);
}

public static void ShouldContain(this string actual, string expected)
{
StringAssert.Contains(expected, actual);
}

public static void ShouldNotContain(this string actual, string expected)
{
try
{
StringAssert.Contains(expected, actual);
}
catch (AssertionException)
{
return;
}

throw new AssertionException(String.Format("\"{0}\" should not contain \"{1}\".", actual, expected));
}

public static string ShouldBeEqualIgnoringCase(this string actual, string expected)
{
StringAssert.AreEqualIgnoringCase(expected, actual);
return expected;
}

public static void ShouldStartWith(this string actual, string expected)
{
StringAssert.StartsWith(expected, actual);
}

public static void ShouldEndWith(this string actual, string expected)
{
StringAssert.EndsWith(expected, actual);
}

public static void ShouldBeSurroundedWith(this string actual, string expectedStartDelimiter, string expectedEndDelimiter)
{
StringAssert.StartsWith(expectedStartDelimiter, actual);
StringAssert.EndsWith(expectedEndDelimiter, actual);
}

public static void ShouldBeSurroundedWith(this string actual, string expectedDelimiter)
{
StringAssert.StartsWith(expectedDelimiter, actual);
StringAssert.EndsWith(expectedDelimiter, actual);
}

public static void ShouldContainErrorMessage(this Exception exception, string expected)
{
StringAssert.Contains(expected, exception.Message);
}

public static Exception ShouldBeThrownBy(this Type exceptionType, MethodThatThrows method)
{
Exception exception = method.GetException();

Assert.IsNotNull(exception);
Assert.AreEqual(exceptionType, exception.GetType());

return exception;
}

public static Exception GetException(this MethodThatThrows method)
{
Exception exception = null;

try
{
method();
}
catch (Exception e)
{
exception = e;
}

return exception;
}
}
}

Change log

r43 by sbellware on May 5, 2008   Diff
-Started adding internals for filtering
the report based on the value of the
string passed to the concern
-Did some code clean up. Much more to do
here, specifically refactoring the report
generator into separate classes
Go to: 
Project members, sign in to write a code review

Older revisions

r41 by sbellware on Mar 18, 2008   Diff
- Added ShouldBe() extension method to
take precedence over ShouldBeOfType
- Obsoleted ShouldBeOfType()
r33 by sbellware on Jan 9, 2008   Diff
- Added "behaves like" feature
- Added help to NAnt build
- Removed spec for SQL DateTime
comparison
r7 by sbellware on Dec 30, 2007   Diff
Added Concern feature
All revisions of this file

File info

Size: 4597 bytes, 190 lines
Powered by Google Project Hosting