This is one of the most useless unit tests I’ve encountered
/// <summary>
///A test for GetByLegalCaseID (int)
///</summary>
[TestMethod()] public void GetTicketByLegalCaseID_Test() {
TicketEntityModel target = new TicketEntityModel();
int ID = 1;
TicketDataSet actual = target.GetByLegalCaseID(ID); Assert.IsNotNull(actual, "TicketDataSet was not returned.");
Assert.IsNotNull(actual.Citation, "No Citation table was returned.");
Assert.IsTrue(actual.Citation.Rows.Count > 0, "No Citation rows were returned.");
Assert.IsNotNull(actual.Ticket, "No Ticket table was returned.");
Assert.IsTrue(actual.Ticket.Rows.Count > 0, "No Ticket rows were returned.");
} |
Unit tests in the Entity Model should concentrate on testing business logic, not Data Access Layer (DAL) logic. Unit tests for DAL objects test data access issues. Furthermore, this Unit Test simply checks to see if the current database has a record with an ID of 1 and, therefore, is non-deterministic. It can fail for many reasons that have nothing to do with the business logic. If GetByLegalCaseID has any business logic in it then unit tests should to be written to test that logic and the dependencies on the DAL would be mocked so a previously setup DataSet is returned with known values. This falls under the “What Burns Me” category.










