Skip to content

Commit

Permalink
test: fix test helper failure messages
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinWilkinson committed Apr 9, 2024
1 parent 2f78b3e commit 1c71d75
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Testing/CASLTests/Helpers/TestHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="TestHelpers.cs" company="KinsonDigital">
// <copyright file="TestHelpers.cs" company="KinsonDigital">
// Copyright (c) KinsonDigital. All rights reserved.
// </copyright>

Expand Down Expand Up @@ -200,14 +200,14 @@ public static void SetArrayFieldToNull<TElements>(this object fieldContainer, st
/// <param name="fieldName">The name of the field.</param>
public static void SetFieldToNull(this object fieldContainer, string fieldName)
{
fieldContainer.Should().NotBeNull("setting the enum field value of a null object is not possible.");
fieldName.Should().NotBeNullOrEmpty("setting an enum field value requires a non-empty or null field name.");
fieldContainer.Should().NotBeNull("setting the field value of a null object is not possible.");
fieldName.Should().NotBeNullOrEmpty("setting an field value requires a non-empty or null field name.");

var allEnumFields = fieldContainer.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
var fields = fieldContainer.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

allEnumFields.Should().HaveCountGreaterThan(0, $"no enum fields exist in the object.");
fields.Should().HaveCountGreaterThan(0, $"no fields exist in the object.");

var foundField = Array.Find(allEnumFields, f => f.Name == fieldName);
var foundField = Array.Find(fields, f => f.Name == fieldName);

foundField.Should().NotBeNull($"a field with the name '{fieldName}' does not exist in the object.");
foundField.FieldType.IsValueType.Should().BeFalse("the field is not a value type.");
Expand All @@ -224,12 +224,11 @@ public static void SetFieldToNull(this object fieldContainer, string fieldName)
/// <returns>The boolean value.</returns>
public static bool GetBoolFieldValue(this object fieldContainer, string fieldName)
{
fieldContainer.Should().NotBeNull("setting the enum field value of a null object is not possible.");
fieldName.Should().NotBeNullOrEmpty("setting an enum field value requires a non-empty or null field name.");
fieldContainer.Should().NotBeNull("getting the bool field value of a null object is not possible.");
fieldName.Should().NotBeNullOrEmpty("getting an bool field value requires a non-empty or null field name.");

var allEnumFields = fieldContainer.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

allEnumFields.Should().HaveCountGreaterThan(0, $"no enum fields exist in the object.");
allEnumFields.Should().HaveCountGreaterThan(0, $"no fields exist in the object.");

var foundField = Array.Find(allEnumFields, f => f.Name == fieldName);

Expand Down

0 comments on commit 1c71d75

Please sign in to comment.