Skip to content

Commit cda0d8e

Browse files
Use Assert.Fail() instead of Assert.True(false) to fail a test
1 parent d2347d4 commit cda0d8e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Src/Tests/Helper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ public static void ComparePrivateField<InstanceType, FieldType>(InstanceType ins
2929
FieldInfo fi = typeof(InstanceType).GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
3030
if (fi is null)
3131
{
32-
Assert.True(false, "The private field was not found.");
32+
Assert.Fail("The private field was not found.");
3333
}
3434

3535
object fieldVal = fi.GetValue(instance);
3636
if (fieldVal is null)
3737
{
38-
Assert.True(false, "The private field value was null.");
38+
Assert.Fail("The private field value was null.");
3939
}
4040
else if (fieldVal is FieldType actual)
4141
{
4242
Assert.Equal(expected, actual);
4343
}
4444
else
4545
{
46-
Assert.True(false, $"Field value is not the same type as expected.{Environment.NewLine}" +
47-
$"Actual type: {fieldVal.GetType()}{Environment.NewLine}" +
48-
$"Expected type: {expected.GetType()}");
46+
Assert.Fail($"Field value is not the same type as expected.{Environment.NewLine}" +
47+
$"Actual type: {fieldVal.GetType()}{Environment.NewLine}" +
48+
$"Expected type: {expected.GetType()}");
4949
}
5050
}
5151

@@ -60,7 +60,7 @@ public static string ReadResources(string resourceName, string fileExtention = "
6060
}
6161
else
6262
{
63-
Assert.True(false, "File was not found among resources!");
63+
Assert.Fail("File was not found among resources!");
6464
return "";
6565
}
6666
}

0 commit comments

Comments
 (0)