public async Task SameResult_NotPlayed_Success() { _teamsService.Setup(x => x.GetTeamSeasonStatsAsync(It.IsAny <int>(), It.IsAny <short>(), It.IsAny <byte>())) .ReturnsAsync(MockedStats()); var service = new TeamsStatsAggregationService(_teamsService.Object, _matchesService.Object); await service.ProcessStreamRecordAsync(MockedRecord(NewMatch(2, 1, false), NewMatch(2, 1, false)), _context.Object); _logger.Verify(x => x.LogLine(It.IsAny <string>()), Times.Exactly(4)); _teamsService.Verify( x => x.AddTeamStatsAsync(It.IsAny <int>(), It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <string>()), Times.Never); _teamsService.Verify(x => x.GetTeamSeasonStatsAsync(It.IsAny <int>(), It.IsAny <short>(), It.IsAny <byte>()), Times.Exactly(2)); _teamsService.Verify(x => x.UpdateTeamStatsAsync(It.IsAny <int>(), It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <TeamSeasonStats>()), Times.Never); }
public void GetStatsError_ThrowException() { _teamsService.Setup(x => x.GetTeamSeasonStatsAsync(It.IsAny <int>(), It.IsAny <short>(), It.IsAny <byte>())) .ThrowsAsync(new DataException()); var service = new TeamsStatsAggregationService(_teamsService.Object, _matchesService.Object); Assert.ThrowsAsync <DataException>(async() => await service.ProcessStreamRecordAsync(MockedRecord(OldMatch(2, 1), NewMatch(2, 3)), _context.Object)); _logger.Verify(x => x.LogLine(It.IsAny <string>()), Times.Exactly(3)); _teamsService.Verify( x => x.AddTeamStatsAsync(It.IsAny <int>(), It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <string>()), Times.Never); _teamsService.Verify(x => x.GetTeamSeasonStatsAsync(It.IsAny <int>(), It.IsAny <short>(), It.IsAny <byte>()), Times.Once); _teamsService.Verify(x => x.UpdateTeamStatsAsync(It.IsAny <int>(), It.IsAny <short>(), It.IsAny <byte>(), It.IsAny <TeamSeasonStats>()), Times.Never); }