Class Assert
A collection of helper classes to test various conditions within unit tests. If the condition being tested is not met, an exception is thrown
Inherited Members
Namespace: PayrollEngine.Client.Test
Assembly: PayrollEngine.Client.Test.dll
Syntax
public static class Assert
Methods
AreEqual<T>(T, T, string)
Tests whether the specified values are equal and throws an exception if the two values are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42
Declaration
public static void AreEqual<T>(T expected, T actual, string message = null)
Parameters
| Type | Name | Description |
|---|---|---|
| T | expected | The expected value |
| T | actual | The actual value |
| string | message | The assert failed message |
Type Parameters
| Name | Description |
|---|---|
| T |
AreNotEqual<T>(T, T, string)
Tests whether the specified values are not equal and throws an exception if the two values are not equal. Different numeric types are treated as unequal even if the logical values are equal. 42L is not equal to 42
Declaration
public static void AreNotEqual<T>(T expected, T actual, string message = null)
Parameters
| Type | Name | Description |
|---|---|---|
| T | expected | The expected value |
| T | actual | The actual value |
| string | message | The assert failed message |
Type Parameters
| Name | Description |
|---|---|
| T |
Fail(string)
Throws an AssertFailedException
Declaration
public static void Fail(string message = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | message | The exception message |
IsFalse(bool, string)
Tests whether the specified condition is false and throws an exception if the condition is true
Declaration
public static void IsFalse(bool condition, string message = null)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | condition | The condition the test expects to be false |
| string | message | The message to include in the exception when condition is true. The message is shown in test results |
IsNotNull(object, string)
Tests whether the specified object is non-null and throws an exception if it is null
Declaration
public static void IsNotNull(object value, string message = null)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The object the test expects not to be null |
| string | message | The message to include in the exception when value is null |
IsNull(object, string)
Tests whether the specified object is null and throws an exception if it is not
Declaration
public static void IsNull(object value, string message = null)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The object the test expects to be null |
| string | message | The message to include in the exception when value is not null |
IsTrue(bool, string)
Tests whether the specified condition is true and throws an exception if the condition is false
Declaration
public static void IsTrue(bool condition, string message = null)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | condition | The condition the test expects to be false |
| string | message | The message to include in the exception when condition is true. The message is shown in test results |