public void RoverMovement_ShouldArgumentException_WhenPositionIsNull() { var testRoverRequest = new TestRoverRequest { TopPositionX = 5, TopPositionY = 5, CurrentX = 1, CurrentY = 2, CurrentFacing = "N", Direction = "", ExpectedFace = "N", ExpectedXCoordinate = 1, ExpectedYCoordinate = 3 }; var roverMovement = new RoverMovement(); var result = Record.Exception(() => roverMovement.RoverMove(testRoverRequest)); Assert.NotNull(result); var exception = Assert.IsType <ArgumentException>(result); var actual = exception.Message; const string expectedErrorMessage = "Direction cannot be null or empty."; Assert.Equal(expectedErrorMessage, actual); }
public void RoverMovement_ShouldArgumentNullException_WhenTopPositionYIsNull() { var testRoverRequest = new TestRoverRequest { TopPositionX = 5, TopPositionY = 0, CurrentX = 1, CurrentY = 2, CurrentFacing = "N", Direction = "LMLMLMLMM", ExpectedFace = "N", ExpectedXCoordinate = 1, ExpectedYCoordinate = 3 }; var roverMovement = new RoverMovement(); var result = Record.Exception(() => roverMovement.RoverMove(testRoverRequest)); Assert.NotNull(result); var exception = Assert.IsType <ArgumentNullException>(result); var actual = exception.ParamName; const string expectedErrorMessage = "TopPositionY with value 0 should be more than zero."; Assert.Equal(expectedErrorMessage, actual); }
public void RoverMovement_ValidObjectPassed_ReturnedResponseModel(TestRoverRequest testRoverRequest) { var roverMovement = new RoverMovement(); var responseModel = roverMovement.RoverMove(testRoverRequest); Assert.IsType <TestRoverRequest>(testRoverRequest); Assert.Equal(testRoverRequest.ExpectedFace, responseModel.Position.Face); Assert.Equal(testRoverRequest.ExpectedXCoordinate, responseModel.Position.xCoordinate); Assert.Equal(testRoverRequest.ExpectedYCoordinate, responseModel.Position.yCoordinate); }
public void RoverMovement_ShouldSuccess_WhenDirectionIsLowercase() { var testRoverRequest = new TestRoverRequest { TopPositionX = 5, TopPositionY = 5, CurrentX = 1, CurrentY = 2, CurrentFacing = "N", Direction = "lmlmlmlmm", ExpectedFace = "N", ExpectedXCoordinate = 1, ExpectedYCoordinate = 3 }; var roverMovement = new RoverMovement(); var responseModel = roverMovement.RoverMove(testRoverRequest); Assert.IsType <TestRoverRequest>(testRoverRequest); Assert.Equal(testRoverRequest.ExpectedFace, responseModel.Position.Face); Assert.Equal(testRoverRequest.ExpectedXCoordinate, responseModel.Position.xCoordinate); Assert.Equal(testRoverRequest.ExpectedYCoordinate, responseModel.Position.yCoordinate); }