public void SetUp() { p = new Player("Jacques", "A cooker"); Loc1 = new Location("a coffee house", " which is a place where everyone can chat while drinking coffee"); Loc2 = new Location("a stable", " where people raise their finest horses"); Path1 = new Path(new string[] { "northwest" }, "a trail", "This is a long trail for you", Loc1, Loc2); Move = new MoveCommand(); p.Location = Loc1; Loc1.AddPath(Path1); }
public void SetUp() { Loc1 = new Location("treehouse", "This is a small, yet picturesque treehouse"); Loc2 = new Location("building gate", "Gate of the central building"); p = new Player("George", "The main player"); newPath = new Path(new string[] { "path", "route" }, "path", "This is the path needed for me", Loc1, Loc2); // For setting location and path for player. p.Location = Loc1; Loc1.AddPath(newPath); }
[Test()] // Test whether Path can Move Player between Locations: public void TestMovePlayer() { List <Location> _locations = new List <Location>(); Player Andrew = new Player("Andrew", "A great student"); Location Bathroom = new Location("Bathroom", "Room in a house"); Location Study = new Location("Study", "Study nook"); Path Hallway = new Path(new string[] { "north", "Hallway in house" }, Bathroom); Path Corridor = new Path(new string[] { "south", "Corridor leading south" }, Study); _locations.Add(Bathroom); _locations.Add(Study); Study.AddPath(Hallway); Bathroom.AddPath(Corridor); Andrew.Location = Bathroom; MoveCommand move = new MoveCommand(_locations); string actual = move.Execute(Andrew, new string[] { "move", "north" }); string expected = "Player moved to " + Study.Name; Assert.AreEqual(actual, expected, "Player not being located to new location correctly"); }
public void TestMovingCommand() { NorthHotel.AddPath(north); Assert.AreEqual("You head north.\nYou travel through northway.\nYou arrive at Motel", _move.Execute(_player, new string[] { "move", "north" })); }