public async Task GetPlayerById_WhenPlayerIdIsZero_ShouldReturnBadRequest() { var playerServiceMock = new Mock <IPlayerService>(); var controller = new TennisPlayerController(playerServiceMock.Object); var result = await controller.GetPlayerById(0); Assert.IsType <BadRequestResult>(result); }
public async Task GetPlayerById_WhenPlayerIdIsFound_ShouldBeHappyPath() { var playerServiceMock = new Mock <IPlayerService>(); playerServiceMock.Setup(e => e.GetAllPlayers()).ReturnsAsync( new System.Collections.Generic.List <Player> { new Player { id = 123 } } ); var controller = new TennisPlayerController(playerServiceMock.Object); var result = await controller.GetPlayerById(123); Assert.IsType <OkObjectResult>(result); }