Skip to content

Commit d3e33f9

Browse files
authored
Add asserts for objects equal and not equal (#180)
***NO_CI***
1 parent 6495f58 commit d3e33f9

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

source/TestFramework/Assert.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,29 @@ public static void False(
108108

109109
#region Equal
110110

111+
/// <summary>
112+
/// Tests whether the specified objects are equal and throws an exception if the two objects are not equal.
113+
/// </summary>
114+
/// <param name="expected">The first objects to compare. This is the objects the tests expects.</param>
115+
/// <param name="actual">The second objects to compare. This is the objects produced by the code under test.</param>
116+
/// <param name="message"> The message to include in the exception when <paramref name="actual"/> is not equal to <paramref name="expected"/>. The message is shown in test results.</param>
117+
/// <exception cref="AssertFailedException">Thrown if <paramref name="expected"/> is not equal to <paramref name="actual"/>.</exception>
118+
public static void AreEqual(
119+
object expected,
120+
object actual,
121+
string message = "")
122+
{
123+
if (expected == actual)
124+
{
125+
return;
126+
}
127+
128+
HandleAreEqualFail(
129+
expected,
130+
actual,
131+
message);
132+
}
133+
111134
/// <summary>
112135
/// Tests whether the specified values are equal and throws an exception if the two values are not equal.
113136
/// </summary>
@@ -699,6 +722,29 @@ public static void Equal(
699722

700723
#region NotEqual
701724

725+
/// <summary>
726+
/// Tests whether the specified object are not equal and throws an exception if the two object are equal.
727+
/// </summary>
728+
/// <param name="notExpected">The first object to compare. This is the object the tests expects.</param>
729+
/// <param name="actual">The second object to compare. This is the object produced by the code under test.</param>
730+
/// <param name="message"> The message to include in the exception when <paramref name="actual"/> is equal to <paramref name="notExpected"/>. The message is shown in test results.</param>
731+
/// <exception cref="AssertFailedException">Thrown if <paramref name="notExpected"/> is equal to <paramref name="actual"/>.</exception>
732+
public static void AreNotEqual(
733+
object notExpected,
734+
object actual,
735+
string message = "")
736+
{
737+
if (notExpected != actual)
738+
{
739+
return;
740+
}
741+
742+
HandleAreNotEqualFail(
743+
notExpected,
744+
actual,
745+
message);
746+
}
747+
702748
/// <summary>
703749
/// Tests whether the specified values are not equal and throws an exception if the two values are equal.
704750
/// </summary>

0 commit comments

Comments
 (0)