I know from the docs I can do this ...
result.Should().BeOfType<MyClass>().Which.Property1.Should().Be("String")
Is there a way I can test multiple properties, in a way similar
result.Should().BeOfType<MyClass>().Which.Property1.Should().Be("String").And.Property2.Should().Be(99);
It's also be good if it were possible to do either of the above tests without having to assert hat they are 'OfType' but I suspect that there is no other way for the code to know what properties are available.
You can do a structural comparison assertion against an anonymous type, like this:
result.ShouldBeEquivalentTo(new
{
Property1 = "String",
Property2 = 99
}, options => options.ExcludingMissingMembers());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With