From one OO theoretical perspective, the Domain classes do not "persist" any data. Rather they are POCO objects that simply represent the data model. It is the DAOs (or DTOs) that persist data and retrieve data.
So, if you agree with this model, then you don't really need to write unit tests for the POCO objects (although I have to find stoopid mistakes like having a public property return the wrong member variable). You would write unit tests for the DAOs. That is where your TDD would start.
So maybe you have a Domain namespace with a Member class. Then you have a DAO namespace with a MemberDAO class. Member unit tests could be simple things like:
Code:
public CreateNewMember() {
Member m = new Member(param1, param2);
Assert.IsNotNull(m, "Member object not instantiated.);
Assert.AreEqual(param1, m.param1, "Params do not match.");
Assert.AreEqual(param2, m.param2, "Params do not match.");
}
Then in your MemberDAOTest class you might do:
Code:
public FindMembersByLastName() {
MemberDAO mDAO = new MemberDAO(dbSession);
IList members = mDAO.FindMembersByLastName("Smith");
foreach (Member m in members) {
Assert.AreEqual("smith", m.LastName, "Last Names do not match.");
}
}
So to make a long answer short, yes, just test your business methods. Test the persistability for each object within your DAO tests. It isn't necessary to Unit Test the POCO objects (although I do).
Just one developer's opinion.
-devon