public void MoveOutOfBoundryTest() { var moveAction = RoverActionPool.GetAction('M'); Plateau plateau = new Plateau() .SetSize(6, 8); var rovers = new Rover[] { plateau.DeployRover(1, 5, 'w'), plateau.DeployRover(2, 6, 'n'), plateau.DeployRover(3, 5, 'e'), plateau.DeployRover(2, 4, 's'), }; foreach (var fo in rovers) { moveAction.ApplyTo(fo); } for (int fo = 0; fo < 4; fo++) { Assert.Throws <InvalidOperationException>(() => moveAction.ApplyTo(rovers[fo])); for (int foRover = fo + 1; foRover < 4; foRover++) { moveAction.ApplyTo(rovers[foRover]); } } }
public static Rover DeployRover(this Plateau plateau, int x, int y, char orientation) { Contract.Requires(plateau != null); Contract.Ensures(Contract.Result <Rover>() != null); return(plateau.DeployRover(new Point(x, y), orientation.ParseAsOrientation())); }