public async Task ShouldReturnNotFoundIfLeagueDoesNotExistsInvokingTotalPlayers() { //ARRANGE const string leagueCode = "invalid League code"; const string expectedMessage = "League: " + leagueCode + " Not Found"; _leagueService.Setup(l => l.TotalPlayersByLeagueCode(leagueCode)).Throws <LeagueNotFoundException>(); var controller = new ImportLeagueController(_leagueService.Object); //ACT var res = await controller.TotalPlayers(leagueCode); //ASSERT var notFoundResult = res as NotFoundObjectResult; Assert.IsNotNull(notFoundResult); Assert.AreEqual(expectedMessage, notFoundResult.Value); }
public async Task ShouldReturnTotalPlayersWithAValidLeagueCode() { //ARRANGE const string leagueCode = "Dummy League code"; const int totalPlayers = 10; _leagueService.Setup(l => l.TotalPlayersByLeagueCode(leagueCode)).Returns(Task.FromResult(totalPlayers)); var controller = new ImportLeagueController(_leagueService.Object); //ACT var res = await controller.TotalPlayers(leagueCode); //ASSERT var okObjectResult = res as OkObjectResult; Assert.IsNotNull(okObjectResult); Assert.AreEqual("total: " + totalPlayers, okObjectResult.Value); }