Merge pull request #1325 from madrang/CryptoToolsCtorCheck
[mono.git] / mcs / nunit24 / NUnitFramework / framework / Assertion.cs
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
6 \r
7 namespace NUnit.Framework \r
8 {\r
9         using System;\r
10 \r
11         /// <summary>\r
12         /// The Assertion class is obsolete and has been\r
13         /// replaced by the Assert class.\r
14         /// </summary>\r
15         [Obsolete("Use Assert class instead")]\r
16         public class Assertion\r
17         {\r
18                 /// <summary>\r
19                 /// Asserts that a condition is true. If it isn't it throws\r
20                 /// an <see cref="AssertionException"/>.\r
21                 /// </summary>\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
26                 {\r
27                         NUnit.Framework.Assert.IsTrue(condition, message);\r
28                 }\r
29     \r
30                 /// <summary>\r
31                 /// Asserts that a condition is true. If it isn't it throws\r
32                 /// an <see cref="AssertionException"/>.\r
33                 /// </summary>\r
34                 /// <param name="condition">The evaluated condition</param>\r
35                 static public void Assert(bool condition) \r
36                 {\r
37                         Assertion.Assert(string.Empty, condition);\r
38                 }\r
39 \r
40                 /// <summary>\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
43                 /// </summary>\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
49                 {\r
50                         Assertion.AssertEquals(string.Empty, expected, actual, delta);\r
51                 }\r
52                 /// <summary>\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
55                 /// </summary>\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
61                 {\r
62                         Assertion.AssertEquals(string.Empty, expected, actual, delta);\r
63                 }\r
64 \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
68                 {\r
69                         Assertion.AssertEquals(string.Empty, expected, actual);\r
70                 }\r
71 \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
75                 {\r
76                         Assertion.AssertEquals(string.Empty, expected, actual);\r
77                 }\r
78 \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
82                 {\r
83                         NUnit.Framework.Assert.AreEqual(expected, actual, message);\r
84                 }\r
85                 \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
88                 /// </summary>\r
89                 static public void AssertEquals(string message, double expected, \r
90                         double actual, double delta) \r
91                 {\r
92                         NUnit.Framework.Assert.AreEqual(expected, actual, delta, message);\r
93                 }\r
94                 \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
97                 /// </summary>\r
98                 static public void AssertEquals(string message, float expected, \r
99                         float actual, float delta) \r
100                 {\r
101                         NUnit.Framework.Assert.AreEqual(expected, actual, delta, message);\r
102                 }\r
103 \r
104                 /// <summary>\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
111                 /// </summary>\r
112                 static public void AssertEquals(string message, Object expected, Object actual)\r
113                 {\r
114                         NUnit.Framework.Assert.AreEqual(expected, actual, message);\r
115                 }\r
116     \r
117                 /// <summary>Asserts that an object isn't null.</summary>\r
118                 static public void AssertNotNull(Object anObject) \r
119                 {\r
120                         NUnit.Framework.Assert.IsNotNull(anObject, string.Empty);\r
121                 }\r
122     \r
123                 /// <summary>Asserts that an object isn't null.</summary>\r
124                 static public void AssertNotNull(string message, Object anObject) \r
125                 {\r
126                         NUnit.Framework.Assert.IsNotNull(anObject, message);\r
127                 }\r
128     \r
129                 /// <summary>Asserts that an object is null.</summary>\r
130                 static public void AssertNull(Object anObject) \r
131                 {\r
132                         NUnit.Framework.Assert.IsNull(anObject, string.Empty);\r
133                 }\r
134     \r
135                 /// <summary>Asserts that an object is null.</summary>\r
136                 static public void AssertNull(string message, Object anObject) \r
137                 {\r
138                         NUnit.Framework.Assert.IsNull(anObject, message);\r
139                 }\r
140     \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
143                 /// </summary>\r
144                 static public void AssertSame(Object expected, Object actual) \r
145                 {\r
146                         NUnit.Framework.Assert.AreSame(expected, actual, string.Empty);\r
147                 }\r
148     \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
151                 /// </summary>\r
152                 static public void AssertSame(string message, Object expected, Object actual)\r
153                 {\r
154                         NUnit.Framework.Assert.AreSame(expected, actual, message);\r
155                 }\r
156     \r
157                 /// <summary>Fails a test with no message.</summary>\r
158                 static public void Fail() \r
159                 {\r
160                         NUnit.Framework.Assert.Fail();\r
161                 }\r
162     \r
163                 /// <summary>Fails a test with the given message.</summary>\r
164                 static public void Fail(string message) \r
165                 {\r
166                         NUnit.Framework.Assert.Fail(message);\r
167                 }\r
168         }\r
169 }\r