Game Development Reference
In-Depth Information
Figure 10.1
Add Reference dialog for the
NUnit framework.
After the NUnit framework reference has been added to your unit test project, you
should have something similar to Figure 10.2. Also be aware that Visual Studio
automatically adds System.Data and System.Xml , and they have been removed from
the references list because they are not needed for this example.
The SimpleLibrary project contains the object we
want to test, and the SimpleLibrary.UnitTesting con-
tains the unit tests that NUnit will execute against
Figure 10.2
Overview of the example project structure.
Attribute Overview
Traditionally, NUnit provided test declaration using inheritance, but this design
posed some problems with languages like C#, where multiple inheritance is not sup-
ported, and the only way to use the test framework is with complex inheritance hier-
archies. The latest version of NUnit now offers a method of declaring tests with
attributes, which is basically a .NET feature that can inject meta-data into an object.
Attributes do not reflect the code being run, but attributes do provide extra infor-
mation about a particular object. The NUnit runner scans all the targeted assemblies
for classes and methods that contain certain attributes and acts on them accordingly.
Search Nedrilad ::

Custom Search