t127 = new Location("a lecture theatre", "T127");
gregsoffice = new Location("a spinning vortex of terror", "Greg's Office");
t127.AddExit("south", new Exit("you see a mound of paper to the south", gregsoffice));
gregsoffice.AddExit("north", new Exit("you see a bleak place to the north", t127));
thePlayer.CurrentLocation = t127;
handler = new CommandHandler();
move = new MoveCommand();
}
[TestMethod]
public void TestMoveNowhere()
{
Assert.AreSame(t127, thePlayer.CurrentLocation);
// test move command no arguments
CommandResponse response = move.Execute(playerInput, thePlayer);
Assert.IsFalse(response.FinishedGame);
Assert.IsTrue(response.Message.Contains("no exit there"));
Assert.AreSame(t127, thePlayer.CurrentLocation);
}
[TestMethod]
public void TestMoveNoExit()
{
playerInput.Arguments = new ArrayList(new string[] { "west" });
CommandResponse response = move.Execute(playerInput, thePlayer);
Assert.IsFalse(response.FinishedGame);
Assert.IsTrue(response.Message.Contains("no exit there"));
Assert.AreSame(t127, thePlayer.CurrentLocation);
}
[TestMethod]
public void TestTakeExit()
{
playerInput.Arguments = new ArrayList(new string[] { "south" });
CommandResponse response = move.Execute(playerInput, thePlayer);
Assert.IsFalse(response.FinishedGame);
Assert.IsTrue(response.Message.Contains(gregsoffice.Description));
Assert.AreSame(gregsoffice, thePlayer.CurrentLocation);
}
[TestMethod]
public void TestMoveHandler()
{
// test move command no arguments
CommandResponse response = handler.ProcessTurn("move to the south", thePlayer);
Assert.IsFalse(response.FinishedGame);
Assert.IsTrue(response.Message.Contains(gregsoffice.Description));
Assert.AreSame(gregsoffice, thePlayer.CurrentLocation);
}
}
}