1 // ***********************************************************************
2 // Copyright (c) 2014 Charlie Poole
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 // ***********************************************************************
26 namespace NUnit.Framework
28 public partial class Assert
30 #region IsAssignableFrom
33 /// Asserts that an object may be assigned a value of a given Type.
35 /// <param name="expected">The expected Type.</param>
36 /// <param name="actual">The object under examination</param>
37 /// <param name="message">The message to display in case of failure</param>
38 /// <param name="args">Array of objects to be used in formatting the message</param>
39 public static void IsAssignableFrom(Type expected, object actual, string message, params object[] args)
41 Assert.That(actual, Is.AssignableFrom(expected) ,message, args);
45 /// Asserts that an object may be assigned a value of a given Type.
47 /// <param name="expected">The expected Type.</param>
48 /// <param name="actual">The object under examination</param>
49 public static void IsAssignableFrom(Type expected, object actual)
51 Assert.That(actual, Is.AssignableFrom(expected) ,null, null);
56 #region IsAssignableFrom<TExpected>
59 /// Asserts that an object may be assigned a value of a given Type.
61 /// <typeparam name="TExpected">The expected Type.</typeparam>
62 /// <param name="actual">The object under examination</param>
63 /// <param name="message">The message to display in case of failure</param>
64 /// <param name="args">Array of objects to be used in formatting the message</param>
65 public static void IsAssignableFrom<TExpected>(object actual, string message, params object[] args)
67 Assert.That(actual, Is.AssignableFrom(typeof(TExpected)) ,message, args);
71 /// Asserts that an object may be assigned a value of a given Type.
73 /// <typeparam name="TExpected">The expected Type.</typeparam>
74 /// <param name="actual">The object under examination</param>
75 public static void IsAssignableFrom<TExpected>(object actual)
77 Assert.That(actual, Is.AssignableFrom(typeof(TExpected)) ,null, null);
82 #region IsNotAssignableFrom
85 /// Asserts that an object may not be assigned a value of a given Type.
87 /// <param name="expected">The expected Type.</param>
88 /// <param name="actual">The object under examination</param>
89 /// <param name="message">The message to display in case of failure</param>
90 /// <param name="args">Array of objects to be used in formatting the message</param>
91 public static void IsNotAssignableFrom(Type expected, object actual, string message, params object[] args)
93 Assert.That(actual, Is.Not.AssignableFrom(expected) ,message, args);
97 /// Asserts that an object may not be assigned a value of a given Type.
99 /// <param name="expected">The expected Type.</param>
100 /// <param name="actual">The object under examination</param>
101 public static void IsNotAssignableFrom(Type expected, object actual)
103 Assert.That(actual, Is.Not.AssignableFrom(expected) ,null, null);
108 #region IsNotAssignableFrom<TExpected>
111 /// Asserts that an object may not be assigned a value of a given Type.
113 /// <typeparam name="TExpected">The expected Type.</typeparam>
114 /// <param name="actual">The object under examination</param>
115 /// <param name="message">The message to display in case of failure</param>
116 /// <param name="args">Array of objects to be used in formatting the message</param>
117 public static void IsNotAssignableFrom<TExpected>(object actual, string message, params object[] args)
119 Assert.That(actual, Is.Not.AssignableFrom(typeof(TExpected)) ,message, args);
123 /// Asserts that an object may not be assigned a value of a given Type.
125 /// <typeparam name="TExpected">The expected Type.</typeparam>
126 /// <param name="actual">The object under examination</param>
127 public static void IsNotAssignableFrom<TExpected>(object actual)
129 Assert.That(actual, Is.Not.AssignableFrom(typeof(TExpected)) ,null, null);
137 /// Asserts that an object is an instance of a given type.
139 /// <param name="expected">The expected Type</param>
140 /// <param name="actual">The object being examined</param>
141 /// <param name="message">The message to display in case of failure</param>
142 /// <param name="args">Array of objects to be used in formatting the message</param>
143 public static void IsInstanceOf(Type expected, object actual, string message, params object[] args)
145 Assert.That(actual, Is.InstanceOf(expected) ,message, args);
149 /// Asserts that an object is an instance of a given type.
151 /// <param name="expected">The expected Type</param>
152 /// <param name="actual">The object being examined</param>
153 public static void IsInstanceOf(Type expected, object actual)
155 Assert.That(actual, Is.InstanceOf(expected) ,null, null);
160 #region IsInstanceOf<TExpected>
163 /// Asserts that an object is an instance of a given type.
165 /// <typeparam name="TExpected">The expected Type</typeparam>
166 /// <param name="actual">The object being examined</param>
167 /// <param name="message">The message to display in case of failure</param>
168 /// <param name="args">Array of objects to be used in formatting the message</param>
169 public static void IsInstanceOf<TExpected>(object actual, string message, params object[] args)
171 Assert.That(actual, Is.InstanceOf(typeof(TExpected)) ,message, args);
175 /// Asserts that an object is an instance of a given type.
177 /// <typeparam name="TExpected">The expected Type</typeparam>
178 /// <param name="actual">The object being examined</param>
179 public static void IsInstanceOf<TExpected>(object actual)
181 Assert.That(actual, Is.InstanceOf(typeof(TExpected)) ,null, null);
186 #region IsNotInstanceOf
189 /// Asserts that an object is not an instance of a given type.
191 /// <param name="expected">The expected Type</param>
192 /// <param name="actual">The object being examined</param>
193 /// <param name="message">The message to display in case of failure</param>
194 /// <param name="args">Array of objects to be used in formatting the message</param>
195 public static void IsNotInstanceOf(Type expected, object actual, string message, params object[] args)
197 Assert.That(actual, Is.Not.InstanceOf(expected) ,message, args);
201 /// Asserts that an object is not an instance of a given type.
203 /// <param name="expected">The expected Type</param>
204 /// <param name="actual">The object being examined</param>
205 public static void IsNotInstanceOf(Type expected, object actual)
207 Assert.That(actual, Is.Not.InstanceOf(expected) ,null, null);
212 #region IsNotInstanceOf<TExpected>
215 /// Asserts that an object is not an instance of a given type.
217 /// <typeparam name="TExpected">The expected Type</typeparam>
218 /// <param name="actual">The object being examined</param>
219 /// <param name="message">The message to display in case of failure</param>
220 /// <param name="args">Array of objects to be used in formatting the message</param>
221 public static void IsNotInstanceOf<TExpected>(object actual, string message, params object[] args)
223 Assert.That(actual, Is.Not.InstanceOf(typeof(TExpected)) ,message, args);
227 /// Asserts that an object is not an instance of a given type.
229 /// <typeparam name="TExpected">The expected Type</typeparam>
230 /// <param name="actual">The object being examined</param>
231 public static void IsNotInstanceOf<TExpected>(object actual)
233 Assert.That(actual, Is.Not.InstanceOf(typeof(TExpected)) ,null, null);