Grasshopper now uses csproj instead of vmwcsproj
[mono.git] / mcs / nunit20 / framework / Assertion.cs
1 #region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
2 /************************************************************************************
3 '
4 ' Copyright  2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
5 ' Copyright  2000-2003 Philip A. Craig
6 '
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 
9 ' software.
10
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:
14 '
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.
18 '
19 ' Portions Copyright  2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
20 ' or Copyright  2000-2003 Philip A. Craig
21 '
22 ' 2. Altered source versions must be plainly marked as such, and must not be 
23 ' misrepresented as being the original software.
24 '
25 ' 3. This notice may not be removed or altered from any source distribution.
26 '
27 '***********************************************************************************/
28 #endregion
29
30 namespace NUnit.Framework 
31 {
32         using System;
33
34         /// <summary>A set of Assert methods.</summary>
35         /// 
36         [Obsolete("Use Assert class instead")]
37         public class Assertion
38         {
39                 /// <summary>
40                 /// Asserts that a condition is true. If it isn't it throws
41                 /// an <see cref="AssertionException"/>.
42                 /// </summary>
43                 /// <param name="message">The message to display is the condition
44                 /// is false</param>
45                 /// <param name="condition">The evaluated condition</param>
46                 static public void Assert(string message, bool condition) 
47                 {
48                         NUnit.Framework.Assert.IsTrue(condition, message);
49                 }
50     
51                 /// <summary>
52                 /// Asserts that a condition is true. If it isn't it throws
53                 /// an <see cref="AssertionException"/>.
54                 /// </summary>
55                 /// <param name="condition">The evaluated condition</param>
56                 static public void Assert(bool condition) 
57                 {
58                         Assertion.Assert(string.Empty, condition);
59                 }
60
61                 /// <summary>
62                 /// /// Asserts that two doubles are equal concerning a delta. If the
63                 /// expected value is infinity then the delta value is ignored.
64                 /// </summary>
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) 
70                 {
71                         Assertion.AssertEquals(string.Empty, expected, actual, delta);
72                 }
73                 /// <summary>
74                 /// /// Asserts that two singles are equal concerning a delta. If the
75                 /// expected value is infinity then the delta value is ignored.
76                 /// </summary>
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) 
82                 {
83                         Assertion.AssertEquals(string.Empty, expected, actual, delta);
84                 }
85
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) 
89                 {
90                         Assertion.AssertEquals(string.Empty, expected, actual);
91                 }
92
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) 
96                 {
97                         Assertion.AssertEquals(string.Empty, expected, actual);
98                 }
99
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) 
103                 {
104                         NUnit.Framework.Assert.AreEqual(expected, actual, message);
105                 }
106                 
107                 /// <summary>Asserts that two doubles are equal concerning a delta.
108                 /// If the expected value is infinity then the delta value is ignored.
109                 /// </summary>
110                 static public void AssertEquals(string message, double expected, 
111                         double actual, double delta) 
112                 {
113                         NUnit.Framework.Assert.AreEqual(expected, actual, delta, message);
114                 }
115                 
116                 /// <summary>Asserts that two floats are equal concerning a delta.
117                 /// If the expected value is infinity then the delta value is ignored.
118                 /// </summary>
119                 static public void AssertEquals(string message, float expected, 
120                         float actual, float delta) 
121                 {
122                         NUnit.Framework.Assert.AreEqual(expected, actual, delta, message);
123                 }
124
125                 /// <summary>
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.
132                 /// </summary>
133                 static public void AssertEquals(string message, Object expected, Object actual)
134                 {
135                         NUnit.Framework.Assert.AreEqual(expected, actual, message);
136                 }
137     
138                 /// <summary>Asserts that an object isn't null.</summary>
139                 static public void AssertNotNull(Object anObject) 
140                 {
141                         NUnit.Framework.Assert.IsNotNull(anObject, string.Empty);
142                 }
143     
144                 /// <summary>Asserts that an object isn't null.</summary>
145                 static public void AssertNotNull(string message, Object anObject) 
146                 {
147                         NUnit.Framework.Assert.IsNotNull(anObject, message);
148                 }
149     
150                 /// <summary>Asserts that an object is null.</summary>
151                 static public void AssertNull(Object anObject) 
152                 {
153                         NUnit.Framework.Assert.IsNull(anObject, string.Empty);
154                 }
155     
156                 /// <summary>Asserts that an object is null.</summary>
157                 static public void AssertNull(string message, Object anObject) 
158                 {
159                         NUnit.Framework.Assert.IsNull(anObject, message);
160                 }
161     
162                 /// <summary>Asserts that two objects refer to the same object. If they
163                 /// are not the same an <see cref="AssertionException"/> is thrown.
164                 /// </summary>
165                 static public void AssertSame(Object expected, Object actual) 
166                 {
167                         NUnit.Framework.Assert.AreSame(expected, actual, string.Empty);
168                 }
169     
170                 /// <summary>Asserts that two objects refer to the same object. 
171                 /// If they are not an <see cref="AssertionException"/> is thrown.
172                 /// </summary>
173                 static public void AssertSame(string message, Object expected, Object actual)
174                 {
175                         NUnit.Framework.Assert.AreSame(expected, actual, message);
176                 }
177     
178                 /// <summary>Fails a test with no message.</summary>
179                 static public void Fail() 
180                 {
181                         NUnit.Framework.Assert.Fail();
182                 }
183     
184                 /// <summary>Fails a test with the given message.</summary>
185                 static public void Fail(string message) 
186                 {
187                         NUnit.Framework.Assert.Fail(message);
188                 }
189         }
190 }