The first statement in the Zebra Problem says, "There are five houses".
Let's write a test that the Zebra class contains a list of five house objects.
At this point we cannot even run the test because the compiler is returning an error. We need to add a ZebraProblem class. Put your cursor on ZebraProblem and press CTRL+. to access the Generate from Usage menu. Select "Generate new type…".
In the Generate New Type dialog, select the ZebraGame project and click Ok.
Three things just happened.
- The ZebraProblem class was added to the ZebraGame project.
- A reference to the ZebraGame project was added to the ZebraGame.Test project.
- "using ZebraGame;" was added to the top of the ZebraProblemTest class. This using statement is not needed. You can remove it.
Let's assert that there are five houses in the ZebraProblem class.
Again we have a compile-time error. We are counting the Houses property of the ZebraProblem class before the property exists. Let's switch over to the ZebraProblem class and create the list of houses.
We created a public property to hold a list of houses. Now we need a House class. CTRL+. on the House and add a class.
Now that we can compile, let's run the test.
1 test failed "System.NullReferenceException"
Although we have a property, it is null. In the ZebraProblem constructor, we need to populate the list with five houses.
We now have 5 houses. Let's run the tests again.
1 test passed