c# - How to test nested collections with FluentAssertions -
i have following spec
bidirectionalgraph fixture = new bidirectionalgraph(); public void verticesshouldbeabletoassociatemultipleedges() { int = 0; int b = 1; int c = 2; fixture.addedge(a, b); fixture.addedge(b, c); fixture.addedge(c, a); fixture.edgesfrom(a).should().beequivalentto ( new []{a, b} , new []{a, c}); }
where edgesfrom defined so
public ienumerable<int[]> edgesfrom(int vertex)
however test fails with
result message: expected collection {{0, 1}, {0, 2}} equivalent {{0, 1}, {0, 2}}.
which doesn't quite makes sense me equivalent. fluentassertions
not work when comparing collections of collections?
that's because collection.should().beequivalentto() uses default equals() implementation of type make sure each item in first collection appears somewhere in 2nd collection. need new equivalency feature introduced in fluent assertions 2.0. unfortunately became aware of confusing syntax (collection.should().beequivalentto() versus shouldallbeequivalentto()).
Comments
Post a Comment