Replies: 3 comments 5 replies
-
For the contrived example, I would probably just go with subject.Name.Should().Be("Dynamo");
subject.Born.Should().BeAfter(10.April(1953)); But I imagine the real scenario is more complex and the subject is a result of another assertion. Currently I've this kind of code several places 😞 var person = persons.Should().ContainSingle().Which;
person.Name.Should().Be("Dynamo");
person.Born.Should().BeAfter(10.April(1953)); It would be nice to allow further chaining persons.Should().ContainSingle()
.Which.Should().Satisfy(p =>
{
p.Name.Should().Be("Dynamo");
p.Born.Should().BeAfter(10.April(1953));
}); |
Beta Was this translation helpful? Give feedback.
5 replies
-
We have a similar API See it's usage |
Beta Was this translation helpful? Give feedback.
0 replies
-
Or use something like this: result.Should().BeEquivalentTo(new
{
Name = "Dynamo",
}, options => options
.Using<DateTime>(a => a.Subject.Should().BeAfter(10.April(1953)))
.WhenTypeIs<DateTime>()); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi 👋🏻
Please have a look at the following contrived example:
I'd like to make assertions on an object's properties of different types (here
string
andDateTime
) and thereby make use of FluentAssertions' wonderful extensions, e. g..BeAfter()
.But all I came up with is the very last line of the snippet and I'm wondering whether there is a more elegant way so that I can keep using the type-specific assertions?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions