Consider the following sample C# Data Transfer Object (DTO):
public class MailingAddress
{
public string StreetAddress {get; set;}
public string City {get; set;}
public string StateOrTerritory {get; set;}
public string PostalCode {get; set;}
}
I can write unit tests to check for someone setting the various string members to null
or empty strings. I could also make the setters private on all the fields so that it has to be constructed via a constructor.
I'm asking about this because the CodeCoverage tool is reporting 0% on all these DTO methods and I'm trying to figure out if there's some reasonable testing I might do here.
I have googled a bit and not come up with a lot. I also searched here but haven't found anything that seems to address this. If I've missed something please link it in the comments.
EDIT:
Someone helpfully suggested that my question might be answered by this question. The thing is that while it doesn't look like there's code being run for the various fields, there is, in fact default code there.
It wouldn't be a case of testing the language features. If someone modifies the default behavior of the get/set pairs then I should have unit tests around them to insure they still behave as expected.