thomhurst / TUnit

A modern, fast and flexible .NET testing framework
MIT License
2.34k stars 37 forks source link

Error with Assertion #1214

Open koddek opened 3 hours ago

koddek commented 3 hours ago

First of all TUnit is AWESOME! so I am converting some of my tests to TUnit. (for learning purposes) :) I am getting an error with the code below. The fluentassertions version works but the TUnit assertion doesn't. Am I doing the assertion wrong or is it a bug? Is there another way I can do this?

var result1 = new ComplexObject(Key: "key", Value: "value");
var result2 = new { Key = "key", Value = "value" };

result1.Should().BeEquivalentTo(result2); // FluentAssertions works
await Assert.That(result1).IsEquivalentTo(result2); // TUnit doesn't work.
// TUnit gives this compile time error: The type arguments for method 'EquivalentToAssertionBuilderWrapper<TActual> TUnit.Assertions.Extensions.GenericIsExtensions.IsEquivalentTo<TActual>(this IValueSource<TActual>, TActual, string)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
thomhurst commented 3 hours ago

It's because the types don't match. I suppose it's a bug because we might want to compare two similar objects that are technically different types. I'll keep this open.

thomhurst commented 1 hour ago

Also glad you like TUnit 😁