public void GetMatchesError_ThrowException() { _repository.Setup(x => x.GetMatchesAsync(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <byte>())).ThrowsAsync(new DataException()); var service = new MatchesService(_repository.Object, null, _mapper); Assert.ThrowsAsync <DataException>(async() => await service.DeleteAllMatchesFromSeasonRoundAsync(Year, Season, Round)); _repository.Verify(x => x.DeleteMatchesAsync(It.IsAny <IEnumerable <DataRepository.DataEntities.Match> >()), Times.Never); }
public async Task Ok_Success() { _repository.Setup(x => x.GetMatchesAsync(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <byte>())) .ReturnsAsync(MockedMatches().ToList()); var service = new MatchesService(_repository.Object, null, _mapper); await service.DeleteAllMatchesFromSeasonRoundAsync(Year, Season, Round); _repository.Verify(x => x.DeleteMatchesAsync(It.IsAny <IEnumerable <DataRepository.DataEntities.Match> >()), Times.Once); _repository.Verify(x => x.GetMatchesAsync(It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <byte>()), Times.Once); }