public async Task ImportLeagueWithInvalidCodeAsyncTest() { var unitOfWork = new UnitOfWork(this.context); var mock = new Mock <ICompetitionService>(); var handler = new Mock <HttpMessageHandler>(); var httpClient = handler.CreateClient(); SetupHandler(handler); var importService = new ImportFootballDataService(mock.Object, httpClient, unitOfWork, GetOptions()); var result = await importService.ImportLeagueAsync("llele"); Assert.Equal(OperationResultType.NotFound, result.GetSucceededValue()); }
public async Task ImportPLLeague2TimesAsync() { var unitOfWork = new UnitOfWork(this.context); var competitionService = new CompetitionService(unitOfWork); var handler = new Mock <HttpMessageHandler>(); var httpClient = handler.CreateClient(); SetupHandler(handler); var importService = new ImportFootballDataService(competitionService, httpClient, unitOfWork, GetOptions()); var result = await importService.ImportLeagueAsync("PL"); Assert.Equal(OperationResultType.Successfull, result.GetSucceededValue()); result = await importService.ImportLeagueAsync("PL"); Assert.Equal(OperationResultType.AlreadyDone, result.GetSucceededValue()); }
public async Task ImportPLLeagueAsync() { var unitOfWork = new UnitOfWork(this.context); var mock = new Mock <ICompetitionService>(); mock.Setup(x => x.CreateFullCompetitionAsync(It.IsAny <Competition>(), It.IsAny <ICollection <Team> >())).ReturnsAsync(new Competition()); var handler = new Mock <HttpMessageHandler>(); var httpClient = handler.CreateClient(); SetupHandler(handler); var importService = new ImportFootballDataService(mock.Object, httpClient, unitOfWork, GetOptions()); var result = await importService.ImportLeagueAsync("PL"); Assert.Equal(OperationResultType.Successfull, result.GetSucceededValue()); mock.Verify(x => x.CreateFullCompetitionAsync(It.IsAny <Competition>(), It.IsAny <ICollection <Team> >()), Times.Once); }