Unit Tests Library¶
The assertions you use inside unit tests. UnitTests.Assert compares values and throws an exception when a condition is not met, which fails the test.
Assert¶
Description¶
Provides static methods to test various conditions within unit tests. If the condition being tested is not met, an exception is thrown.
Methods¶
AreEqual(Object, Object)¶
Description
Tests whether the specified values are equal and throws an exception if the two values are not equal.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| expected | Object | Expected value |
| actual | Object | Actual value |
Syntax
AreEqual(Object, Object, string)¶
Description
Tests whether the specified values are equal and throws an exception if the two values are not equal.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| expected | Object | Expected value |
| actual | Object | Actual value |
| message | string | Error message |
Syntax
AreNotEqual(Object, Object)¶
Description
Tests whether the specified values are not equal and throws an exception if the two values are equal.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| expected | Object | Expected value |
| actual | Object | Actual value |
Syntax
AreNotEqual(Object, Object, string)¶
Description
Tests whether the specified values are not equal and throws an exception if the two values are equal.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| expected | Object | Expected value |
| actual | Object | Actual value |
| message | string | Error message |
Syntax
var value = Domain.Customer.GetAge();
UnitTests.Assert.AreNotEqual(22, value, "Wrong Customer Age");
IsTrue(bool)¶
Description
Tests whether the specified condition is true and throws an exception otherwise.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| condition | bool | Condition to evaluate |
Syntax
IsTrue(bool, string)¶
Description
Tests whether the specified condition is true and throws an exception otherwise.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| condition | bool | Condition to evaluate |
| message | string | Error message |
Syntax
IsFalse(bool)¶
Description
Tests whether the specified condition is true and throws an exception otherwise.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| condition | bool | Condition to evaluate |
Syntax
IsFalse(bool, string)¶
Description
Tests whether the specified condition is true and throws an exception otherwise.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| condition | bool | Expected value |
| message | string | Error message |
Syntax
IsNull(value)¶
Description
Tests whether the specified object is null and throws an exception otherwise.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| value | value | Value to test |
Syntax
IsNull(value, string)¶
Description
Tests whether the specified object is null and throws an exception otherwise.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| value | value | Value to test |
| message | string | Error message |
Syntax
var value = Domain.Customer.Find(c => c.Name == 'Default').First();
UnitTests.Assert.IsNull(value, "Customer not found");
IsNotNull(value)¶
Description
Tests whether the specified object is not null and throws an exception otherwise.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| value | value | Value to test |
Syntax
var value = Domain.Customer.Find(c => c.Name == 'Default').First();
UnitTests.Assert.IsNotNull(value);
IsNotNull(value, string)¶
Description
Tests whether the specified object is not null and throws an exception otherwise.
Return Type : void
Static : Yes
Namespace : UnitTests.Assert
Parameters
| Name | Data Type | Description |
|---|---|---|
| value | value | Value to test |
| message | string | Error message |
Syntax
var value = Domain.Customer.Find(c => c.Name == 'Default').First();
UnitTests.Assert.IsNotNull(value, "Customer not found");