c# - CollectionAssert of an nested List -
how assert nested list too, without 'unnesting' it?
expected.add(new customer{ edition = "cust", rarity = "r", id = 1001, name = "john doe", types = new list<type_>{ new type_{ id = 1, name = "abc" } },
here assert:
collectionassert.areequal(expected, actual);
that exclude nested list.
something worked me:
- generate object hash (such md5) includes content of list, quite rigid approach , seldom useful
- just write second assert in test inner list. more conventional approach (my favourite)
- write new test assert inner list. more tdd-purist approach
edit, here example of conventional approach:
var expected = new list<type_>{ new type_{ id = 1, name = "abc" }; collectionassert.areequal(expected, actual.types);
Comments
Post a Comment