Writing Unit Tests Against Direct3D

Writing a unit test involves holding the “system under test” in a software vise and controlling all the other interactions of the system under test with the rest of the system. In an object-oriented programming language, the easiest way to control the interactions of your system under test with the rest of the universe is to interact with the universe through polymorphic interfaces. Because your system under test is collaborating with the universe through interfaces, it is not coupled to other concrete classes in your application. To unit test the system and its interactions, you provide “fake” or “mock” objects implementing the interfaces of the system’s collaborators. The system under test has no idea its collaborating with fake objects because it is coupled to an interface, not a concrete class.

Read the rest of this entry »