Search code examples
.netunit-testingagile

What unit tests should be written for simple POCO domain objects?


So standard Agile philosophy would recommend making your domain classes simple POCOs which are Persisted using a separate proxy layer via data access objects (like NHibernate does it). It also recommends getting as high unit test coverage as possible.

Does it make any sense to write tests for these simple POCO objects? Say I have a class which looks like this:

public class Container {
 public int ContainerId { get; set;}
 public string Name { get; set;}
 public IList<Item> Contents { get; set;}
}

What useful unit tests can I write for this?


Solution

  • Typically a value object like that doesn't need to have its own tests. You'll get coverage from the classes that use it to actually do something.

    The unit tests are designed to test behavior. No behavior? No need for a test.