diff --git a/TUnit.Assertions.UnitTests/EquivalentAssertionTests.cs b/TUnit.Assertions.UnitTests/EquivalentAssertionTests.cs index 47206e825d..ab08c9a308 100644 --- a/TUnit.Assertions.UnitTests/EquivalentAssertionTests.cs +++ b/TUnit.Assertions.UnitTests/EquivalentAssertionTests.cs @@ -232,6 +232,37 @@ public async Task Objects_With_Nested_Matches_Are_Equivalent() await TUnitAssert.That(object1).IsEquivalentTo(object2); } + [Test] + public async Task Struct_Objects_With_Nested_Matches_Are_Equivalent() + { + var object1 = new MyStruct + { + Value = "Foo", + Inner = new InnerClass + { + Value = "Bar", + Inner = new InnerClass + { + Value = "Baz" + } + } + }; + var object2 = new MyStruct + { + Value = "Foo", + Inner = new InnerClass + { + Value = "Bar", + Inner = new InnerClass + { + Value = "Baz" + } + } + }; + + await TUnitAssert.That(object1).IsEquivalentTo(object2); + } + [Test] public void Objects_With_Nested_Enumerable_Mismatch_Are_Not_Equivalent() { @@ -359,4 +390,10 @@ public class InnerClass public IEnumerable? Collection { get; set; } } + + public struct MyStruct + { + public string? Value { get; set; } + public InnerClass? Inner { get; set; } + } } \ No newline at end of file diff --git a/TUnit.Assertions/Compare.cs b/TUnit.Assertions/Compare.cs index f14d81d2e5..c482c5fecb 100644 --- a/TUnit.Assertions/Compare.cs +++ b/TUnit.Assertions/Compare.cs @@ -61,7 +61,6 @@ private static IEnumerable CheckEquivalent< if (actual.GetType().IsPrimitive || actual.GetType().IsEnum - || actual.GetType().IsValueType || actual is string) { yield return new ComparisonFailure