Why can't I do the following with FluentAssertions, using the 'And' property?
SomeObject.Should()
   .BeAssignableTo<OtherObject>()
   .And
   .SomeStringProperty.Should().StartWith("whatever");
That will not compile because after the And it doesn't know that it's a SomeObject type. Instead, I have to use 'Which' in place of And, which I thought was used for collections, not single objects. The Which version does compile but the semantics aren't as clear
Which will give you a reference to SomeObject, but cast as OtherObject. So your example will change to:
SomeObject.Should()
   .BeAssignableTo<OtherObject>()
   .Which.SomeStringProperty.Should().StartWith("whatever");
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