Unit Testing Procedures

Unit tests should take care of all possible scenarios for an individual method. GateShift generally uses Visual Studio 2008 Testing Tools for all unit tests. Work will be put in later to support NUnit testing with the same code. You can use the InternalsVisibleTo Attribute to gain access to internal members. The Private Accessor should be used for private members.

Data Access Layer Testing

Testing the Data Layer should test the Entities and their default values and validations. It should test the repository objects and verify they work with correct and incorrect data. It should also be able to mock up data for testing. The following naming scheme for classes should be followed:
  • Mock<TableName> - Class used for mocking up the IData when storing data is not needed
    • Use Get/Set for all fields
  • <TableName>Test - Class used to test an entity by the IData interface
    • Test default field values
    • Test length being too long
    • Test setting a field to null for non-nullable fields
    • Test setting the field's value and then retrieving it
  • <TableName>Helper - Class used to create test data in the database or sample database objects
    • Create value generators
    • Create sample object
    • Create and save item in the database
    • Allow creation with specific ID references (besides the table ID)
  • <TableName>RepositoryTest - Class used for testing the repository for saving, retrieving, deleting, and updating data
    • Test invalid IData based objects (non-ADO.NET entities or the technology being used)
    • Test created objects (type and defaults)
    • Test null IData values
    • Test invalid states (i.e. saving deleted objects)
  • DBHelper - Class for clearing the database or managing global database tasks

Last edited Feb 19, 2009 at 10:43 PM by TMYates, version 2

Comments

No comments yet.