You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var expectedEvent = new { ContactId = testContact.ContactId, };
As you can see expectedEvent is an anonymous type. If PracticeId is missing the assertion still pass.
I would expect that if there is a missing member in any of the two objects being compared the assertion should fail. I don't have too much experience using the library, I am not sure how the assertion works but I read the description of the method saying if any of the two objects have mismatch amount of properties the assertion should not pass, so I figured this might not be the desired behavior.
If I do the opposite (remove PracticeId from the ContactCreatedEvent and add it to the anonymous type) the assertion fails.
I am using anonymous type because this object actually has a lot of collection properties where I would like to exclude id fields given I don't care if they match but unfortunately I read here fluentassertions/fluentassertions#500 that there is no easy way to exclude all members of a collection from an assertion
Thank you!
The text was updated successfully, but these errors were encountered:
Thank you for contacting us. The behavior you're seeing is by design. If your expectation has only a single property, then FA will only validate that your subject has the same property with the same (equivalent) value. This was a big change in 5.0.0.
But I do see the XML comments are a bit misleading. We'll update those.
Hey guys, I noticed a weird behavior today using
BeEquivalentTo
, would you let me know if this is expected or if there is a work around:I am using version 5.10.3
I have a class with the following set of properties
`public class ContactCreatedEvent()
{
public Guid ContactId { get; }
}`
I am asserting that my event should be equivalent to my expected event this way
contactCreatedEvent.Should().BeEquivalentTo(expectedEvent);
Where expected event is
var expectedEvent = new { ContactId = testContact.ContactId, };
As you can see expectedEvent is an anonymous type. If PracticeId is missing the assertion still pass.
I would expect that if there is a missing member in any of the two objects being compared the assertion should fail. I don't have too much experience using the library, I am not sure how the assertion works but I read the description of the method saying if any of the two objects have mismatch amount of properties the assertion should not pass, so I figured this might not be the desired behavior.
If I do the opposite (remove PracticeId from the ContactCreatedEvent and add it to the anonymous type) the assertion fails.
I am using anonymous type because this object actually has a lot of collection properties where I would like to exclude id fields given I don't care if they match but unfortunately I read here fluentassertions/fluentassertions#500 that there is no easy way to exclude all members of a collection from an assertion
Thank you!
The text was updated successfully, but these errors were encountered: