Zebra Game Kata Part 6 - The Australian lives in the house with the red door.

Now that we have all of our enumerations set, we can write a fun test.

2. The Australian lives in the house with the red door.

public void Australian_lives_in_the_house_with_the_red_door()
        h => h.Nationality == Nationality.Australian
        && h.DoorColor == DoorColor.Red),
        "The Australian needs to live "
        + "in the house with the red door.");

Let's talk about this LINQ statement.

We are looking for any house where the nationality is Australian and the door color is red.

If we do not find a house, write out a helpful message.

We can compile, let's run the test.

1 test failed "The Australian needs to live in the house with the red door."

To get the test to pass we need to give the house with the Australian a red door.

new House
    Id = 1,
    DoorColor = DoorColor.Red,
    Nationality = Nationality.Australian,
    Pet = Pet.Dog,
    Drink = Drink.Coffee,
    Food = Food.Apple,

Let's run the tests again.

1 tests failed "A house was found with the same color door as house 1."

House 1 used to have a blue door. When we switched it to red, we failed our unique door color test.

That's the great thing about test driven development. We can make changes, run the tests, and see if anything went wrong. Let's give house 4 the blue door that used to be on house 1.

new House
    Id = 4,
    DoorColor = DoorColor.Blue,
    Nationality = Nationality.Norwegian,
    Pet = Pet.Snails,
    Drink = Drink.Tea,
    Food = Food.Mushroom,

Let's run the tests again.

8 tests passed

Now we need to do the same thing for these parts:

3. The Italian owns the dog.

4. Coffee is drunk in the house with the green door.

5. The Ukrainian drinks tea.

7. The mushroom-eater owns snails.

8. Apples are eaten in the house with the yellow door.

13. The cake-eater drinks orange juice.

14. The Japanese eats bananas.