Is it necessary to unit test a value object, and how would you go about it?
Take for instance this object:
public class TeamProfile
{
public string Name { get; set; }
public int Wins { get; set; }
public int Losses { get; set; }
public int Draws { get; set; }
}
The answer is an opinion. I would say NO. But such questions really arise in day to day work and I understand the question so let me give some more opinion:
I would judge based on specific situation. If you think “my unit test routines do test it all” (and rely on it) and you see any likelihood above routines could ever change towards something more sophisticated then the answer is YES. Questions like these I sometimes answer with YES only to find out after a while it was really overkill. Then on other occasions I judge “oh no man this is really overkill” only to find out later that there was an aspect I never thought of.
How to test it? As all test cases: Define input and expected result. Set it. Get it. Check whether get is what you’ve set.