Skip to content

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

var value = Domain.Customer.GetAge();
UnitTests.Assert.AreEqual(22, value);



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

var value = Domain.Customer.GetAge();
UnitTests.Assert.AreEqual(22, value, "Wrong Customer Age");



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

var value = Domain.Customer.GetAge();
UnitTests.Assert.AreNotEqual(22, value);



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

var value = Domain.Customer.IsGood();
UnitTests.Assert.IsTrue(value);



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

var value = Domain.Customer.IsGood();
UnitTests.Assert.IsTrue(value, "Customer should be good");



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

var value = Domain.Customer.IsGood();
UnitTests.Assert.IsFalse(value);



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

var value = Domain.Customer.IsGood();
UnitTests.Assert.IsFalse(value, "Customer should be bad");



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

var value = Domain.Customer.Find(c => c.Name == 'Default').First();
UnitTests.Assert.IsNull(value);



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");



Back to top