public void StageAddLawnMower_CalledTwice_AddsTwoLawnMowersToMowersWithMovementInstructionsAtExpectedIndex() { //Arrange string[] argsSplit = "5 5\n1 2 N\nLMLMLMLMM\n3 3 E\nMMRMMMRMRMM".Split(new[] { "\n" }, StringSplitOptions.None); var lawn = new Lawn(5, 5); var stage = new Stage(lawn); var mowerInitializationTuples = ProgramWithPublicMethods.GetMowerInitializationTuples(argsSplit); //Act stage.AddLawnMower(mowerInitializationTuples[0].Item1, mowerInitializationTuples[0].Item2, mowerInitializationTuples[0].Item3, mowerInitializationTuples[0].Item4); stage.AddLawnMower(mowerInitializationTuples[1].Item1, mowerInitializationTuples[1].Item2, mowerInitializationTuples[1].Item3, mowerInitializationTuples[1].Item4); //Assert lawnMower1 inputs Assert.AreEqual(1, stage.MowersWithMovementInstructions[0].Item1.XCord); Assert.AreEqual(2, stage.MowersWithMovementInstructions[0].Item1.YCord); Assert.AreEqual(CompassDirection.N, stage.MowersWithMovementInstructions[0].Item1.Heading); StringAssert.IsMatch("LMLMLMLMM", stage.MowersWithMovementInstructions[0].Item2); //Assert lawnMower2 inputs Assert.AreEqual(3, stage.MowersWithMovementInstructions[1].Item1.XCord); Assert.AreEqual(3, stage.MowersWithMovementInstructions[1].Item1.YCord); Assert.AreEqual(CompassDirection.E, stage.MowersWithMovementInstructions[1].Item1.Heading); StringAssert.IsMatch("MMRMMMRMRMM", stage.MowersWithMovementInstructions[1].Item2); }
public void LawnPlaceLawnMower_PassedLawnMowerWithXAndYAlreadyOccupied_ThrowsMowerPositionOccupiedException() { //Arrange ILawn lawn = new Lawn(5, 5); var mower1 = new LawnMower(0, 0, CompassDirection.N, ref lawn); //Act //Assert Assert.Throws<Lawn.LawnMowerPositionOccupiedException>(() => new LawnMower(0, 0, CompassDirection.N, ref lawn)); }
public void LawnPlaceMower_PassedLawnMowerWithXOrYOutOfRange_ThrowsIndexOutOfRangeException() { //Arrange ILawn lawn = new Lawn(5, 5); var lawnMower = new LawnMower(1, 2, CompassDirection.N, ref lawn); //Act //Assert Assert.Throws<IndexOutOfRangeException>(() => lawn.PlaceLawnMower(lawnMower, 6, 6)); }
public void LawnConstructor_Passed55_ReturnsLawnWithMowerPositonsXAndYlengthsOf6() { //Arrange //Act ILawn lawn = new Lawn(5,5); //Assert Assert.AreEqual(6, lawn.LawnMowerPostions.GetLength(0)); Assert.AreEqual(6, lawn.LawnMowerPostions.GetLength(1)); }
protected static ILawn GetLawn(string xYArgs) { if (string.IsNullOrEmpty(xYArgs)) throw new ArgumentException("xYArgs cannot be null or string.empty"); int x; int y; GetLawnMaxXy(xYArgs, out x, out y); var lawn = new Lawn(x, y); return lawn; }
public CompassDirection LawnMowerSetNewHeading_CalledWithCurrentHeadingAndARotation_SetsLawnMowerHeading(CompassDirection compassDirection, int rotation) { //Arrange ILawn lawn = new Lawn(5, 5); var lawnMower = new LawnMowerWithPublicMethods(0, 0, compassDirection, ref lawn); //Act lawnMower.SetNewHeading(rotation); //Assert return lawnMower.Heading; }