1 // ****************************************************************
\r
2 // This is free software licensed under the NUnit license. You
\r
3 // may obtain a copy of the license as well as information regarding
\r
4 // copyright ownership at http://nunit.org/?p=license&r=2.4.
\r
5 // ****************************************************************
\r
7 namespace NUnit.Framework
\r
12 /// The Assertion class is obsolete and has been
\r
13 /// replaced by the Assert class.
\r
15 [Obsolete("Use Assert class instead")]
\r
16 public class Assertion
\r
19 /// Asserts that a condition is true. If it isn't it throws
\r
20 /// an <see cref="AssertionException"/>.
\r
22 /// <param name="message">The message to display is the condition
\r
23 /// is false</param>
\r
24 /// <param name="condition">The evaluated condition</param>
\r
25 static public void Assert(string message, bool condition)
\r
27 NUnit.Framework.Assert.IsTrue(condition, message);
\r
31 /// Asserts that a condition is true. If it isn't it throws
\r
32 /// an <see cref="AssertionException"/>.
\r
34 /// <param name="condition">The evaluated condition</param>
\r
35 static public void Assert(bool condition)
\r
37 Assertion.Assert(string.Empty, condition);
\r
41 /// /// Asserts that two doubles are equal concerning a delta. If the
\r
42 /// expected value is infinity then the delta value is ignored.
\r
44 /// <param name="expected">The expected value</param>
\r
45 /// <param name="actual">The actual value</param>
\r
46 /// <param name="delta">The maximum acceptable difference between the
\r
47 /// the expected and the actual</param>
\r
48 static public void AssertEquals(double expected, double actual, double delta)
\r
50 Assertion.AssertEquals(string.Empty, expected, actual, delta);
\r
53 /// /// Asserts that two singles are equal concerning a delta. If the
\r
54 /// expected value is infinity then the delta value is ignored.
\r
56 /// <param name="expected">The expected value</param>
\r
57 /// <param name="actual">The actual value</param>
\r
58 /// <param name="delta">The maximum acceptable difference between the
\r
59 /// the expected and the actual</param>
\r
60 static public void AssertEquals(float expected, float actual, float delta)
\r
62 Assertion.AssertEquals(string.Empty, expected, actual, delta);
\r
65 /// <summary>Asserts that two objects are equal. If they are not
\r
66 /// an <see cref="AssertionException"/> is thrown.</summary>
\r
67 static public void AssertEquals(Object expected, Object actual)
\r
69 Assertion.AssertEquals(string.Empty, expected, actual);
\r
72 /// <summary>Asserts that two ints are equal. If they are not
\r
73 /// an <see cref="AssertionException"/> is thrown.</summary>
\r
74 static public void AssertEquals(int expected, int actual)
\r
76 Assertion.AssertEquals(string.Empty, expected, actual);
\r
79 /// <summary>Asserts that two ints are equal. If they are not
\r
80 /// an <see cref="AssertionException"/> is thrown.</summary>
\r
81 static public void AssertEquals(string message, int expected, int actual)
\r
83 NUnit.Framework.Assert.AreEqual(expected, actual, message);
\r
86 /// <summary>Asserts that two doubles are equal concerning a delta.
\r
87 /// If the expected value is infinity then the delta value is ignored.
\r
89 static public void AssertEquals(string message, double expected,
\r
90 double actual, double delta)
\r
92 NUnit.Framework.Assert.AreEqual(expected, actual, delta, message);
\r
95 /// <summary>Asserts that two floats are equal concerning a delta.
\r
96 /// If the expected value is infinity then the delta value is ignored.
\r
98 static public void AssertEquals(string message, float expected,
\r
99 float actual, float delta)
\r
101 NUnit.Framework.Assert.AreEqual(expected, actual, delta, message);
\r
105 /// Asserts that two objects are equal. Two objects are considered
\r
106 /// equal if both are null, or if both have the same value. Numeric
\r
107 /// types are compared via string comparision on their contents to
\r
108 /// avoid problems comparing values between different types. All
\r
109 /// non-numeric types are compared by using the <c>Equals</c> method.
\r
110 /// If they are not equal an <see cref="AssertionException"/> is thrown.
\r
112 static public void AssertEquals(string message, Object expected, Object actual)
\r
114 NUnit.Framework.Assert.AreEqual(expected, actual, message);
\r
117 /// <summary>Asserts that an object isn't null.</summary>
\r
118 static public void AssertNotNull(Object anObject)
\r
120 NUnit.Framework.Assert.IsNotNull(anObject, string.Empty);
\r
123 /// <summary>Asserts that an object isn't null.</summary>
\r
124 static public void AssertNotNull(string message, Object anObject)
\r
126 NUnit.Framework.Assert.IsNotNull(anObject, message);
\r
129 /// <summary>Asserts that an object is null.</summary>
\r
130 static public void AssertNull(Object anObject)
\r
132 NUnit.Framework.Assert.IsNull(anObject, string.Empty);
\r
135 /// <summary>Asserts that an object is null.</summary>
\r
136 static public void AssertNull(string message, Object anObject)
\r
138 NUnit.Framework.Assert.IsNull(anObject, message);
\r
141 /// <summary>Asserts that two objects refer to the same object. If they
\r
142 /// are not the same an <see cref="AssertionException"/> is thrown.
\r
144 static public void AssertSame(Object expected, Object actual)
\r
146 NUnit.Framework.Assert.AreSame(expected, actual, string.Empty);
\r
149 /// <summary>Asserts that two objects refer to the same object.
\r
150 /// If they are not an <see cref="AssertionException"/> is thrown.
\r
152 static public void AssertSame(string message, Object expected, Object actual)
\r
154 NUnit.Framework.Assert.AreSame(expected, actual, message);
\r
157 /// <summary>Fails a test with no message.</summary>
\r
158 static public void Fail()
\r
160 NUnit.Framework.Assert.Fail();
\r
163 /// <summary>Fails a test with the given message.</summary>
\r
164 static public void Fail(string message)
\r
166 NUnit.Framework.Assert.Fail(message);
\r