Reputation: 1407
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
Upvotes: 4
Views: 1860
Reputation: 8889
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");
Upvotes: 5