Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing a value object

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; }
}
like image 925
Nick Larsen Avatar asked Sep 28 '26 14:09

Nick Larsen


1 Answers

There is an excellent article on Value Objects and their introduction and testing by Dan Bergh Johnsson http://www.infoq.com/presentations/Value-Objects-Dan-Bergh-Johnsson

For clarity I must reiterate that the example given is not a value object. http://martinfowler.com/bliki/ValueObject.html

It is specifically either a command, message or more likely a (DTO) Data Transfer Object As others have mentioned, the provided class has no behaviour to test.

like image 107
James Avatar answered Sep 30 '26 04:09

James



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!