I'm using xUnit.net, AutoFixture and SemanticComparison and want to verify the results of a mapping.
On the individual item level, I'm well covered.
Given
- The items share an identifying key
- I want to do a comparison on the value elements on both side
- I don't care about ordering (and don't want my Assertion to break under re-ordering)
How do I verify that each and every input item maps to one and only one output item in a DAMP yet DRY manner using as much OOTB componentry as possible ?
Fixtures:
class Input
{
public string Name, Description;
}
class Output
{
public string Name, Description, IgnoreThisField;
}
Skeleton Test:
[Theory,AutoData]
void MappingWorks( Mapper sut, Input[] inputs)
{
var outputs = sut.Map( inputs);
// TODO assert that every input is mapped
// TODO assert that we have have no extra outputs
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…