public void SystemTimeCanBeResetAfterBeingMocked() { SystemTimeMocker.SetOneSecondAfter(DateTime.Now.AddDays(oneDay)); SystemTimeMocker.Reset(); SystemTime.Now.Should().BeCloseTo(DateTime.Now, acceptableInaccuracy); }
public void GivenGroupsWithinTournamentIsPlayedOutAndBettedOn(Table table) { if (table == null) { throw new ArgumentNullException(nameof(table)); } foreach (TableRow row in table.Rows) { TestUtilities.ParseTargetGroupToPlay(row, out int tournamentIndex, out int roundIndex, out int groupIndex); bool tournamentIndexIsValid = createdTournaments.Count > tournamentIndex; bool roundIndexIsValid = createdTournaments[tournamentIndex].Rounds.Count > roundIndex; bool groupIndexIsValid = createdTournaments[tournamentIndex].Rounds[roundIndex].Groups.Count > groupIndex; if (!tournamentIndexIsValid || !roundIndexIsValid || !groupIndexIsValid) { throw new IndexOutOfRangeException("Tournament, round, or group with given index does not exist"); } SystemTimeMocker.Reset(); Tournament tournament = createdTournaments[tournamentIndex]; RoundBase round = tournament.Rounds[roundIndex]; GroupBase group = round.Groups[groupIndex]; while (group.GetPlayState() != PlayStateEnum.Finished) { bool tournamentHasBetters = tournament.Betters.Count > 0; if (tournamentHasBetters) { PlaceBetsOnAvailableMatchesInGroup(tournament.Betters, group); } foreach (Match match in group.Matches) { if (match.IsReady() && match.GetPlayState() == PlayStateEnum.NotBegun) { SystemTimeMocker.SetOneSecondAfter(match.StartDateTime); break; } } bool playedMatchesSuccessfully = PlayAvailableMatches(group); if (!playedMatchesSuccessfully) { break; } } } }
public void GivenGroupsWithinTournamentIsPlayedOut(string tournamentName, Table table) { using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { foreach (TableRow row in table.Rows) { TestUtilities.ParseTargetGroupToPlay(row, out int _, out int roundIndex, out int groupIndex); SystemTimeMocker.Reset(); Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName); RoundBase round = tournament.Rounds[roundIndex]; GroupBase group = round.Groups[groupIndex]; foreach (Match match in group.Matches) { PlayMatch(tournamentRepository, match); } tournamentRepository.Save(); } } }
public static void AfterScenario() { SystemTimeMocker.Reset(); }
public void Dispose() { SystemTimeMocker.Reset(); }
public SystemTimeTests() { SystemTimeMocker.Reset(); }