fluent assertions - FluentAssertions: check a list contains an object, excluding a property -
i have several event classes implement ievent. check actual event against expected event use
actualevent.shouldbeequivalentto(expectedevent,opt => opt.respectingruntimetypes() .excluding(e => e.datecreated));
the events have datecreated property ignore actual , expected created @ different times.
how check if expectedevent exists @ least once in list of actualevents?
i following;
actualevents.should().contain(expectedevent,opt => opt.respectingruntimetypes() .excluding(e => e.datecreated));
but not possible.
can done in fluentassertions?
i had similar scenario had list of items (an object properties) , wanted check if list contained local item testing for.
i found solution on question: fluentassertions, making sure ienumerable contains single element
i simplified solution writing following statement:
foolist.should().contain(fooitem, x => true)
the above constraint states foolist object should contain fooitem expressed lambda x => true.
fairly straight forward , worked use case. give try , check out question thread linked may help.
good luck.
Comments
Post a Comment