public async Task GivenAlreadyImportedLeagueCodeShouldReturnConflict() { var controller = new FootballController(MockComponentsProvider(GetInMemoryDbContext())); await controller.Import("BL1"); var result = await controller.Import("BL1"); var objectResult = result as ConflictObjectResult; Assert.NotNull(objectResult); var value = objectResult.Value.ToString(); Assert.True(value == "{ Message = League already imported }"); }
public async Task GivenInvalidLeagueCodeImportShouldReturn404() { var controller = new FootballController(MockComponentsProvider(GetInMemoryDbContext())); var result = await controller.Import(Guid.NewGuid().ToString()); var objectResult = result as NotFoundObjectResult; Assert.NotNull(objectResult); var value = objectResult.Value.ToString(); Assert.True(value == "{ Message = Not found }"); }
public async Task GivenValidLeagueCodeImportShouldStoreData() { var controller = new FootballController(MockComponentsProvider(GetInMemoryDbContext())); var result = await controller.Import("BL1"); var objectResult = result as ObjectResult; Assert.NotNull(objectResult); Assert.True(objectResult.StatusCode == 201); var value = objectResult.Value.ToString(); Assert.True(value == "{ Message = Successfully imported }"); }
public async Task GivenValidLeagueCodeShouldReturnPlayerCount() { var componentsProvider = MockComponentsProvider(GetInMemoryDbContext()); var footballController = new FootballController(componentsProvider); var playerController = new PlayerController(componentsProvider); await footballController.Import("BL1"); var result = await playerController.TotalPlayers("BL1"); var objectResult = result as OkObjectResult; Assert.NotNull(objectResult); var value = objectResult.Value.ToString(); Assert.True(value == "{ total = 1184 }"); }