Assert Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A collection of helper classes to test various conditions within unit tests. If the condition being tested is not met, an exception is thrown.
public class Assert
public sealed class Assert
public static class Assert
type Assert = class
Public Class Assert
Public NotInheritable Class Assert
- Inheritance
-
Assert
Constructors
Assert() |
Properties
That |
Gets the singleton instance of the Assert functionality. |
Methods
AreEqual(Decimal, Decimal, Decimal, String, Object[]) |
Tests whether the specified decimals are equal and throws an exception if they are not equal. |
AreEqual(Decimal, Decimal, Decimal, String) |
Tests whether the specified decimals are equal and throws an exception if they are not equal. |
AreEqual(Decimal, Decimal, Decimal) |
Tests whether the specified decimals are equal and throws an exception if they are not equal. |
AreEqual(Double, Double, Double, String, Object[]) |
Tests whether the specified doubles are equal and throws an exception if they are not equal. |
AreEqual(Double, Double, Double, String) |
Tests whether the specified doubles are equal and throws an exception if they are not equal. |
AreEqual(Double, Double, Double) |
Tests whether the specified doubles are equal and throws an exception if they are not equal. |
AreEqual(Int64, Int64, Int64, String, Object[]) |
Tests whether the specified longs are equal and throws an exception if they are not equal. |
AreEqual(Int64, Int64, Int64, String) |
Tests whether the specified longs are equal and throws an exception if they are not equal. |
AreEqual(Int64, Int64, Int64) |
Tests whether the specified longs are equal and throws an exception if they are not equal. |
AreEqual(Object, Object, String, Object[]) |
Tests whether the specified objects are equal and throws an exception if the two objects are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. |
AreEqual(Object, Object, String) |
Tests whether the specified objects are equal and throws an exception if the two objects are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. |
AreEqual(Object, Object) |
Tests whether the specified objects are equal and throws an exception if the two objects are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. |
AreEqual(Single, Single, Single, String, Object[]) |
Tests whether the specified floats are equal and throws an exception if they are not equal. |
AreEqual(Single, Single, Single, String) |
Tests whether the specified floats are equal and throws an exception if they are not equal. |
AreEqual(Single, Single, Single) |
Tests whether the specified floats are equal and throws an exception if they are not equal. |
AreEqual(String, String, Boolean, CultureInfo, String, Object[]) |
Tests whether the specified strings are equal and throws an exception if they are not equal. |
AreEqual(String, String, Boolean, CultureInfo, String) |
Tests whether the specified strings are equal and throws an exception if they are not equal. |
AreEqual(String, String, Boolean, CultureInfo) |
Tests whether the specified strings are equal and throws an exception if they are not equal. |
AreEqual(String, String, Boolean, String, Object[]) |
Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison. |
AreEqual(String, String, Boolean, String) |
Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison. |
AreEqual(String, String, Boolean) |
Tests whether the specified strings are equal and throws an exception if they are not equal. The invariant culture is used for the comparison. |
AreEqual<T>(IEquatable<T>, IEquatable<T>, String, Object[]) |
Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>. |
AreEqual<T>(IEquatable<T>, IEquatable<T>, String) |
Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>. |
AreEqual<T>(IEquatable<T>, IEquatable<T>) |
Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>. |
AreEqual<T>(T, T, IEqualityComparer<T>, String, Object[]) |
Tests whether the specified values are equal and throws an exception
if the two values are not equal.
The equality is computed using the provided |
AreEqual<T>(T, T, IEqualityComparer<T>, String) |
Tests whether the specified values are equal and throws an exception
if the two values are not equal.
The equality is computed using the provided |
AreEqual<T>(T, T, IEqualityComparer<T>) |
Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>. |
AreEqual<T>(T, T, String, Object[]) |
Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>. |
AreEqual<T>(T, T, String) |
Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>. |
AreEqual<T>(T, T) |
Tests whether the specified values are equal and throws an exception if the two values are not equal. The equality is computed using the default EqualityComparer<T>. |
AreNotEqual(Decimal, Decimal, Decimal, String, Object[]) |
Tests whether the specified decimals are unequal and throws an exception if they are equal. |
AreNotEqual(Decimal, Decimal, Decimal, String) |
Tests whether the specified decimals are unequal and throws an exception if they are equal. |
AreNotEqual(Decimal, Decimal, Decimal) |
Tests whether the specified decimals are unequal and throws an exception if they are equal. |
AreNotEqual(Double, Double, Double, String, Object[]) |
Tests whether the specified doubles are unequal and throws an exception if they are equal. |
AreNotEqual(Double, Double, Double, String) |
Tests whether the specified doubles are unequal and throws an exception if they are equal. |
AreNotEqual(Double, Double, Double) |
Tests whether the specified doubles are unequal and throws an exception if they are equal. |
AreNotEqual(Int64, Int64, Int64, String, Object[]) |
Tests whether the specified longs are unequal and throws an exception if they are equal. |
AreNotEqual(Int64, Int64, Int64, String) |
Tests whether the specified longs are unequal and throws an exception if they are equal. |
AreNotEqual(Int64, Int64, Int64) |
Tests whether the specified longs are unequal and throws an exception if they are equal. |
AreNotEqual(Object, Object, String, Object[]) |
Tests whether the specified objects are unequal and throws an exception if the two objects are equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. |
AreNotEqual(Object, Object, String) |
Tests whether the specified objects are unequal and throws an exception if the two objects are equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. |
AreNotEqual(Object, Object) |
Tests whether the specified objects are unequal and throws an exception if the two objects are equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42. |
AreNotEqual(Single, Single, Single, String, Object[]) |
Tests whether the specified floats are unequal and throws an exception if they are equal. |
AreNotEqual(Single, Single, Single, String) |
Tests whether the specified floats are unequal and throws an exception if they are equal. |
AreNotEqual(Single, Single, Single) |
Tests whether the specified floats are unequal and throws an exception if they are equal. |
AreNotEqual(String, String, Boolean, CultureInfo, String, Object[]) |
Tests whether the specified strings are unequal and throws an exception if they are equal. |
AreNotEqual(String, String, Boolean, CultureInfo, String) |
Tests whether the specified strings are unequal and throws an exception if they are equal. |
AreNotEqual(String, String, Boolean, CultureInfo) |
Tests whether the specified strings are unequal and throws an exception if they are equal. |
AreNotEqual(String, String, Boolean, String, Object[]) |
Tests whether the specified strings are unequal and throws an exception if they are equal. The invariant culture is used for the comparison. |
AreNotEqual(String, String, Boolean, String) |
Tests whether the specified strings are unequal and throws an exception if they are equal. The invariant culture is used for the comparison. |
AreNotEqual(String, String, Boolean) |
Tests whether the specified strings are unequal and throws an exception if they are equal. The invariant culture is used for the comparison. |
AreNotEqual<T>(T, T, IEqualityComparer<T>, String, Object[]) |
Tests whether the specified values are unequal and throws an exception
if the two values are equal.
The equality is computed using the provided |
AreNotEqual<T>(T, T, IEqualityComparer<T>, String) |
Tests whether the specified values are unequal and throws an exception
if the two values are equal.
The equality is computed using the provided |
AreNotEqual<T>(T, T, IEqualityComparer<T>) |
Tests whether the specified values are unequal and throws an exception
if the two values are equal.
The equality is computed using the provided |
AreNotEqual<T>(T, T, String, Object[]) |
Tests whether the specified values are unequal and throws an exception if the two values are equal. The equality is computed using the default EqualityComparer<T>. |
AreNotEqual<T>(T, T, String) |
Tests whether the specified values are unequal and throws an exception if the two values are equal. The equality is computed using the default EqualityComparer<T>. |
AreNotEqual<T>(T, T) |
Tests whether the specified values are unequal and throws an exception if the two values are equal. The equality is computed using the default EqualityComparer<T>. |
AreNotSame(Object, Object, String, Object[]) |
Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object. |
AreNotSame(Object, Object, String) |
Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object. |
AreNotSame(Object, Object) |
Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object. |
AreNotSame<T>(T, T, String, Object[]) |
Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object. |
AreNotSame<T>(T, T, String) |
Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object. |
AreNotSame<T>(T, T) |
Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object. |
AreSame(Object, Object, String, Object[]) |
Tests whether the specified objects both refer to the same object and throws an exception if the two inputs do not refer to the same object. |
AreSame(Object, Object, String) |
Tests whether the specified objects both refer to the same object and throws an exception if the two inputs do not refer to the same object. |
AreSame(Object, Object) |
Tests whether the specified objects both refer to the same object and throws an exception if the two inputs do not refer to the same object. |
AreSame<T>(T, T, String, Object[]) |
Tests whether the specified objects both refer to the same object and throws an exception if the two inputs do not refer to the same object. |
AreSame<T>(T, T, String) |
Tests whether the specified objects both refer to the same object and throws an exception if the two inputs do not refer to the same object. |
AreSame<T>(T, T) |
Tests whether the specified objects both refer to the same object and throws an exception if the two inputs do not refer to the same object. |
Equals(Object, Object) |
Static equals overloads are used for comparing instances of two types for reference equality. This method should not be used for comparison of two instances for equality. This object will always throw with Assert.Fail. Please use Assert.AreEqual and associated overloads in your unit tests. |
Fail() |
Throws an AssertFailedException. |
Fail(String, Object[]) |
Throws an AssertFailedException. |
Fail(String) |
Throws an AssertFailedException. |
Inconclusive() |
Throws an AssertInconclusiveException. |
Inconclusive(String, Object[]) |
Throws an AssertInconclusiveException. |
Inconclusive(String) |
Throws an AssertInconclusiveException. |
IsFalse(Boolean, String, Object[]) |
Tests whether the specified condition is false and throws an exception if the condition is true. |
IsFalse(Boolean, String) |
Tests whether the specified condition is false and throws an exception if the condition is true. |
IsFalse(Boolean) |
Tests whether the specified condition is false and throws an exception if the condition is true. |
IsFalse(Nullable<Boolean>, String, Object[]) |
Tests whether the specified condition is false and throws an exception if the condition is true. |
IsFalse(Nullable<Boolean>, String) |
Tests whether the specified condition is false and throws an exception if the condition is true. |
IsFalse(Nullable<Boolean>) |
Tests whether the specified condition is false and throws an exception if the condition is true. |
IsInstanceOfType(Object, Type, String, Object[]) |
Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object. |
IsInstanceOfType(Object, Type, String) |
Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object. |
IsInstanceOfType(Object, Type) |
Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object. |
IsInstanceOfType<T>(Object, String, Object[]) |
Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object. |
IsInstanceOfType<T>(Object, String) |
Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object. |
IsInstanceOfType<T>(Object, T, String, Object[]) |
Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object. |
IsInstanceOfType<T>(Object, T, String) |
Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object. |
IsInstanceOfType<T>(Object, T) |
Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object. |
IsInstanceOfType<T>(Object) |
Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object. |
IsNotInstanceOfType(Object, Type, String, Object[]) |
Tests whether the specified object is not an instance of the wrong type and throws an exception if the specified type is in the inheritance hierarchy of the object. |
IsNotInstanceOfType(Object, Type, String) |
Tests whether the specified object is not an instance of the wrong type and throws an exception if the specified type is in the inheritance hierarchy of the object. |
IsNotInstanceOfType(Object, Type) |
Tests whether the specified object is not an instance of the wrong type and throws an exception if the specified type is in the inheritance hierarchy of the object. |
IsNotInstanceOfType<T>(Object, String, Object[]) |
Tests whether the specified object is not an instance of the wrong generic type and throws an exception if the specified type is in the inheritance hierarchy of the object. |
IsNotInstanceOfType<T>(Object, String) |
Tests whether the specified object is not an instance of the wrong generic type and throws an exception if the specified type is in the inheritance hierarchy of the object. |
IsNotInstanceOfType<T>(Object) |
Tests whether the specified object is not an instance of the wrong generic type and throws an exception if the specified type is in the inheritance hierarchy of the object. |
IsNotNull(Object, String, Object[]) |
Tests whether the specified object is non-null and throws an exception if it is null. |
IsNotNull(Object, String) |
Tests whether the specified object is non-null and throws an exception if it is null. |
IsNotNull(Object) |
Tests whether the specified object is non-null and throws an exception if it is null. |
IsNull(Object, String, Object[]) |
Tests whether the specified object is null and throws an exception if it is not. |
IsNull(Object, String) |
Tests whether the specified object is null and throws an exception if it is not. |
IsNull(Object) |
Tests whether the specified object is null and throws an exception if it is not. |
IsTrue(Boolean, String, Object[]) |
Tests whether the specified condition is true and throws an exception if the condition is false. |
IsTrue(Boolean, String) |
Tests whether the specified condition is true and throws an exception if the condition is false. |
IsTrue(Boolean) |
Tests whether the specified condition is true and throws an exception if the condition is false. |
IsTrue(Nullable<Boolean>, String, Object[]) |
Tests whether the specified condition is true and throws an exception if the condition is false. |
IsTrue(Nullable<Boolean>, String) |
Tests whether the specified condition is true and throws an exception if the condition is false. |
IsTrue(Nullable<Boolean>) |
Tests whether the specified condition is true and throws an exception if the condition is false. |
ReplaceNullChars(String) |
Replaces null characters ('\0') with "\0". |
ThrowsException<T>(Action, String, Object[]) |
Tests whether the code specified by delegate |
ThrowsException<T>(Action, String) |
Tests whether the code specified by delegate |
ThrowsException<T>(Action) |
Tests whether the code specified by delegate |
ThrowsException<T>(Func<Object>, String, Object[]) |
Tests whether the code specified by delegate |
ThrowsException<T>(Func<Object>, String) |
Tests whether the code specified by delegate |
ThrowsException<T>(Func<Object>) |
Tests whether the code specified by delegate |
ThrowsExceptionAsync<T>(Func<Task>, String, Object[]) |
Tests whether the code specified by delegate |
ThrowsExceptionAsync<T>(Func<Task>, String) |
Tests whether the code specified by delegate |
ThrowsExceptionAsync<T>(Func<Task>) |
Tests whether the code specified by delegate |