Zebra Game Kata Part 7 - Green door to the right of ivory door.

6. The house with the green door is immediately to the right (your right) of the house with the ivory door.

So far we have been putting things in to houses. Now we need to find out where a house is in relation to another house.

Ivory
Ivory door
Green
Green door
ZebraGame.Test/ZebraProblemTest.cs
[Test]
public void Green_door_is_immediately_to_the_right_of_ivory_door()
{
    var greenDoorHouse = zebraProblem.Houses.Where(h => 
        h.DoorColor == DoorColor.Green).First();

    var ivoryDoorHouse = zebraProblem.Houses.Where(h => 
        h.DoorColor == DoorColor.Ivory).First();

    Assert.IsTrue(ivoryDoorHouse.Id + 1 == greenDoorHouse.Id,
        "The house with the green door is immediately "
        + "to the right (your right) of the house with "
        + "the ivory door.");
}

Let's talk about this LINQ statement.

We query the collection for the house with the green and ivory door.

Based on that we add 1 to the ivory house's ID. If that equals the green door's ID, we are good. The green door house is immediately to the right of the ivory house.

It's up to you to move the green and ivory doors around to get this test to pass.

Now you know how to get a house from a LINQ. See if you can write tests for these cases:

9. Milk is drunk in the middle house.

10. The Norwegian lives in the first house on the left.

11. The person who eats onions lives in the house next to the person with the fox.

12. Apples are eaten in the house next to the house where the horse is kept.

15. The Norwegian lives next to the house with the blue door.