Merge pull request #1319 from directhex/systemwide-per-arch-aot-cache
[mono.git] / mcs / nunit24 / NUnitFramework / framework / AssertionHelper.cs
1 // ****************************************************************\r
2 // Copyright 2007, Charlie Poole\r
3 // This is free software licensed under the NUnit license. You may\r
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4\r
5 // ****************************************************************\r
6 \r
7 using System;\r
8 using System.Collections;\r
9 using NUnit.Framework.SyntaxHelpers;\r
10 using NUnit.Framework.Constraints;\r
11 \r
12 namespace NUnit.Framework\r
13 {\r
14         /// <summary>\r
15         /// AssertionHelper is an optional base class for user tests,\r
16         /// allowing the use of shorter names for constraints and\r
17         /// asserts and avoiding conflict with the definition of \r
18         /// <see cref="Is"/>, from which it inherits much of its\r
19         /// behavior, in certain mock object frameworks.\r
20         /// </summary>\r
21         public class AssertionHelper : ConstraintBuilder\r
22         {\r
23                 #region Expect\r
24                 /// <summary>\r
25                 /// Apply a constraint to an actual value, succeeding if the constraint\r
26                 /// is satisfied and throwing an assertion exception on failure. Works\r
27                 /// identically to <see cref="NUnit.Framework.Assert.That(object, Constraint)"/>\r
28                 /// </summary>\r
29                 /// <param name="constraint">A Constraint to be applied</param>\r
30                 /// <param name="actual">The actual value to test</param>\r
31                 static public void Expect( object actual, Constraint constraint )\r
32                 {\r
33                         Assert.That( actual, constraint, null, null );\r
34                 }\r
35 \r
36                 /// <summary>\r
37                 /// Apply a constraint to an actual value, succeeding if the constraint\r
38                 /// is satisfied and throwing an assertion exception on failure. Works\r
39                 /// identically to <see cref="NUnit.Framework.Assert.That(object, Constraint, string)"/>\r
40                 /// </summary>\r
41                 /// <param name="constraint">A Constraint to be applied</param>\r
42                 /// <param name="actual">The actual value to test</param>\r
43                 /// <param name="message">The message that will be displayed on failure</param>\r
44                 static public void Expect( object actual, Constraint constraint, string message )\r
45                 {\r
46                         Assert.That( actual, constraint, message, null );\r
47                 }\r
48 \r
49                 /// <summary>\r
50                 /// Apply a constraint to an actual value, succeeding if the constraint\r
51                 /// is satisfied and throwing an assertion exception on failure. Works\r
52                 /// identically to <see cref="NUnit.Framework.Assert.That(object, Constraint, string, object[])"/>\r
53                 /// </summary>\r
54                 /// <param name="constraint">A Constraint to be applied</param>\r
55                 /// <param name="actual">The actual value to test</param>\r
56                 /// <param name="message">The message that will be displayed on failure</param>\r
57                 /// <param name="args">Arguments to be used in formatting the message</param>\r
58                 static public void Expect( object actual, Constraint constraint, string message, params object[] args )\r
59                 {\r
60                         Assert.That( actual, constraint, message, args );\r
61                 }\r
62 \r
63                 /// <summary>\r
64                 /// Asserts that a condition is true. If the condition is false the method throws\r
65                 /// an <see cref="AssertionException"/>. Works Identically to \r
66         /// <see cref="Assert.That(bool, string, object[])"/>.\r
67                 /// </summary> \r
68                 /// <param name="condition">The evaluated condition</param>\r
69                 /// <param name="message">The message to display if the condition is false</param>\r
70                 /// <param name="args">Arguments to be used in formatting the message</param>\r
71                 static public void Expect(bool condition, string message, params object[] args)\r
72                 {\r
73                         Assert.That(condition, Is.True, message, args);\r
74                 }\r
75 \r
76                 /// <summary>\r
77                 /// Asserts that a condition is true. If the condition is false the method throws\r
78                 /// an <see cref="AssertionException"/>. Works Identically to \r
79         /// <see cref="Assert.That(bool, string)"/>.\r
80                 /// </summary>\r
81                 /// <param name="condition">The evaluated condition</param>\r
82                 /// <param name="message">The message to display if the condition is false</param>\r
83                 static public void Expect(bool condition, string message)\r
84                 {\r
85                         Assert.That(condition, Is.True, message, null);\r
86                 }\r
87 \r
88                 /// <summary>\r
89                 /// Asserts that a condition is true. If the condition is false the method throws\r
90                 /// an <see cref="AssertionException"/>. Works Identically to <see cref="Assert.That(bool)"/>.\r
91                 /// </summary>\r
92                 /// <param name="condition">The evaluated condition</param>\r
93                 static public void Expect(bool condition)\r
94                 {\r
95                         Assert.That(condition, Is.True, null, null);\r
96                 }\r
97                 #endregion\r
98 \r
99                 #region Map\r
100                 /// <summary>\r
101                 /// Returns a ListMapper based on a collection.\r
102                 /// </summary>\r
103                 /// <param name="original">The original collection</param>\r
104                 /// <returns></returns>\r
105                 public ListMapper Map( ICollection original )\r
106                 {\r
107                         return new ListMapper( original );\r
108                 }\r
109                 #endregion\r
110         }\r
111 }\r