1 #region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
2 /************************************************************************************
4 ' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
5 ' Copyright 2000-2003 Philip A. Craig
7 ' This software is provided 'as-is', without any express or implied warranty. In no
8 ' event will the authors be held liable for any damages arising from the use of this
11 ' Permission is granted to anyone to use this software for any purpose, including
12 ' commercial applications, and to alter it and redistribute it freely, subject to the
13 ' following restrictions:
15 ' 1. The origin of this software must not be misrepresented; you must not claim that
16 ' you wrote the original software. If you use this software in a product, an
17 ' acknowledgment (see the following) in the product documentation is required.
19 ' Portions Copyright 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
20 ' or Copyright 2000-2003 Philip A. Craig
22 ' 2. Altered source versions must be plainly marked as such, and must not be
23 ' misrepresented as being the original software.
25 ' 3. This notice may not be removed or altered from any source distribution.
27 '***********************************************************************************/
30 namespace NUnit
.Framework
34 /// <summary>A set of Assert methods.</summary>
36 [Obsolete("Use Assert class instead")]
37 public class Assertion
40 /// Asserts that a condition is true. If it isn't it throws
41 /// an <see cref="AssertionException"/>.
43 /// <param name="message">The message to display is the condition
45 /// <param name="condition">The evaluated condition</param>
46 static public void Assert(string message
, bool condition
)
48 NUnit
.Framework
.Assert
.IsTrue(condition
, message
);
52 /// Asserts that a condition is true. If it isn't it throws
53 /// an <see cref="AssertionException"/>.
55 /// <param name="condition">The evaluated condition</param>
56 static public void Assert(bool condition
)
58 Assertion
.Assert(string.Empty
, condition
);
62 /// /// Asserts that two doubles are equal concerning a delta. If the
63 /// expected value is infinity then the delta value is ignored.
65 /// <param name="expected">The expected value</param>
66 /// <param name="actual">The actual value</param>
67 /// <param name="delta">The maximum acceptable difference between the
68 /// the expected and the actual</param>
69 static public void AssertEquals(double expected
, double actual
, double delta
)
71 Assertion
.AssertEquals(string.Empty
, expected
, actual
, delta
);
74 /// /// Asserts that two singles are equal concerning a delta. If the
75 /// expected value is infinity then the delta value is ignored.
77 /// <param name="expected">The expected value</param>
78 /// <param name="actual">The actual value</param>
79 /// <param name="delta">The maximum acceptable difference between the
80 /// the expected and the actual</param>
81 static public void AssertEquals(float expected
, float actual
, float delta
)
83 Assertion
.AssertEquals(string.Empty
, expected
, actual
, delta
);
86 /// <summary>Asserts that two objects are equal. If they are not
87 /// an <see cref="AssertionException"/> is thrown.</summary>
88 static public void AssertEquals(Object expected
, Object actual
)
90 Assertion
.AssertEquals(string.Empty
, expected
, actual
);
93 /// <summary>Asserts that two ints are equal. If they are not
94 /// an <see cref="AssertionException"/> is thrown.</summary>
95 static public void AssertEquals(int expected
, int actual
)
97 Assertion
.AssertEquals(string.Empty
, expected
, actual
);
100 /// <summary>Asserts that two ints are equal. If they are not
101 /// an <see cref="AssertionException"/> is thrown.</summary>
102 static public void AssertEquals(string message
, int expected
, int actual
)
104 NUnit
.Framework
.Assert
.AreEqual(expected
, actual
, message
);
107 /// <summary>Asserts that two doubles are equal concerning a delta.
108 /// If the expected value is infinity then the delta value is ignored.
110 static public void AssertEquals(string message
, double expected
,
111 double actual
, double delta
)
113 NUnit
.Framework
.Assert
.AreEqual(expected
, actual
, delta
, message
);
116 /// <summary>Asserts that two floats are equal concerning a delta.
117 /// If the expected value is infinity then the delta value is ignored.
119 static public void AssertEquals(string message
, float expected
,
120 float actual
, float delta
)
122 NUnit
.Framework
.Assert
.AreEqual(expected
, actual
, delta
, message
);
126 /// Asserts that two objects are equal. Two objects are considered
127 /// equal if both are null, or if both have the same value. Numeric
128 /// types are compared via string comparision on their contents to
129 /// avoid problems comparing values between different types. All
130 /// non-numeric types are compared by using the <c>Equals</c> method.
131 /// If they are not equal an <see cref="AssertionException"/> is thrown.
133 static public void AssertEquals(string message
, Object expected
, Object actual
)
135 NUnit
.Framework
.Assert
.AreEqual(expected
, actual
, message
);
138 /// <summary>Asserts that an object isn't null.</summary>
139 static public void AssertNotNull(Object anObject
)
141 NUnit
.Framework
.Assert
.IsNotNull(anObject
, string.Empty
);
144 /// <summary>Asserts that an object isn't null.</summary>
145 static public void AssertNotNull(string message
, Object anObject
)
147 NUnit
.Framework
.Assert
.IsNotNull(anObject
, message
);
150 /// <summary>Asserts that an object is null.</summary>
151 static public void AssertNull(Object anObject
)
153 NUnit
.Framework
.Assert
.IsNull(anObject
, string.Empty
);
156 /// <summary>Asserts that an object is null.</summary>
157 static public void AssertNull(string message
, Object anObject
)
159 NUnit
.Framework
.Assert
.IsNull(anObject
, message
);
162 /// <summary>Asserts that two objects refer to the same object. If they
163 /// are not the same an <see cref="AssertionException"/> is thrown.
165 static public void AssertSame(Object expected
, Object actual
)
167 NUnit
.Framework
.Assert
.AreSame(expected
, actual
, string.Empty
);
170 /// <summary>Asserts that two objects refer to the same object.
171 /// If they are not an <see cref="AssertionException"/> is thrown.
173 static public void AssertSame(string message
, Object expected
, Object actual
)
175 NUnit
.Framework
.Assert
.AreSame(expected
, actual
, message
);
178 /// <summary>Fails a test with no message.</summary>
179 static public void Fail()
181 NUnit
.Framework
.Assert
.Fail();
184 /// <summary>Fails a test with the given message.</summary>
185 static public void Fail(string message
)
187 NUnit
.Framework
.Assert
.Fail(message
);