public void MoveRoverSync_Test(bool isCoordinateNull) { //Arrange var maxPoints = MockData.MaxPoints; var currentLocation = MockData.CurrentLocation; var movement = MockData.Movement; var coordinates = MockData.Coordinates(); if (!isCoordinateNull) { A.CallTo(() => _invoker.StartMoving(A <Command> ._, A <Coordinates> ._)).ReturnsLazily(() => coordinates); } else { A.CallTo(() => _invoker.StartMoving(A <Command> ._, A <Coordinates> ._)).ReturnsLazily(() => null); } //Act var result = _marsRoverProblemSolutionService.MoveRoverSync(maxPoints, currentLocation, movement, _invoker); //Assert if (!isCoordinateNull) { Assert.NotNull(result); Assert.Equal(coordinates.X, result.X); Assert.Equal(coordinates.Y, result.Y); Assert.Equal(coordinates.Dir, result.Dir); } else { Assert.Null(result); } }
public void Execute_Test(Directions directions) { //Arrange var coordinates = MockData.Coordinates(); switch (directions) { case Directions.N: coordinates.Dir = Directions.N; break; case Directions.E: coordinates.Dir = Directions.E; break; case Directions.S: coordinates.Dir = Directions.S; break; case Directions.W: coordinates.Dir = Directions.W; break; } //Act var result = _command.Execute(coordinates); //Assert Assert.NotNull(result); Assert.Equal(coordinates, result); }
public void ExecuteTest_Failure(bool isYExceed, bool isXExceed, bool isYLess, bool isXLess) { //Arrange var coordinates = MockData.Coordinates(); if (isYExceed) { coordinates.Y = 6; coordinates.Dir = Directions.N; } if (isXExceed) { coordinates.X = 6; coordinates.Dir = Directions.E; } if (isYLess) { coordinates.Y = 0; coordinates.Dir = Directions.S; } if (isXLess) { coordinates.X = 0; coordinates.Dir = Directions.W; } //Act var result = _command.Execute(coordinates); //Assert Assert.Null(result); }
public void StartMovingSync_Test() { //Arrange var coordinates = MockData.Coordinates(); A.CallTo(() => _command.Execute(A <Coordinates> ._)).ReturnsLazily(() => coordinates); //Act var result = _invoker.StartMoving(_command, coordinates); //Assert Assert.NotNull(result); Assert.Equal(result, coordinates); }