This project is read-only.
In many cases you want to test that the mapping works, the actual setting of the properties, and the actual conversion of values. Glue helps you with all that.

Given these classes:

class DomainPerson { public String FirstName { get; set; } }
class GuiPerson { public String FirstName { get; set; } }

And this mapping:

var mapping = new Mapping<DomainPerson, GuiPerson>();

You can make a test run these:

var verification = mapping.GetMapperVerification();
verification.AssertMapsCorrectlyTowards(new DomainPerson());

They will create random values to feed through the converters (in this case, no special converters have been used) and into the actual target object (an instance DomainPerson in this case).

If the values are not set correctly for one reason or the other, an informative exception will be thrown.

Nested types

You should also note that the Map-testing also verifies the mapping of any nested types. That also implies that if you have nested types, you must instantiate them, like this:

verification.AssertMapsCorrectlyTowards(new GuiPerson{Address = new GuiAddress()});

Last edited Aug 8, 2009 at 4:34 PM by ToreVestues, version 4


No comments yet.