Skip to content

Chapter 10 Hide and Seek test (HouseTests) #39

@DarwinsCorn

Description

@DarwinsCorn

The code below for the test for the House class of the project have the following asserts, for which the the first three seem to be written correctly (they use House.Entry). The ones for kitchen and the rest of the rooms of the house seem to be incorrect as they are defined in the House as "var" within a static constructor and are not field members of the class and thus would not be accessible directly outside it as described in the solution.

Unless I'm missing something let me know.

incorrect (from below):

     var kitchen = hallway.GetExit(Direction.Northwest);
     Assert.AreEqual("Kitchen", kitchen.Name);

correct (what it should be):

     var kitchen = House.Entry.Exits[Direction.NorthWest];
     Assert.AreEqual("Kitchen",kitchen.Name);

(Excerpt from the solution) as written in the addendum project solution online:

    [TestMethod]
    public void TestLayout()
    {
        Assert.AreEqual("Entry", House.Entry.Name);

        var garage = House.Entry.GetExit(Direction.Out);
        Assert.AreEqual("Garage", garage.Name);

        var hallway = House.Entry.GetExit(Direction.East);
        Assert.AreEqual("Hallway", hallway.Name);

        var kitchen = hallway.GetExit(Direction.Northwest);
        Assert.AreEqual("Kitchen", kitchen.Name);

        var bathroom = hallway.GetExit(Direction.North);
        Assert.AreEqual("Bathroom", bathroom.Name);

     ....
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions