示例#1
0
        public void SystemTimeCanBeResetAfterBeingMocked()
        {
            SystemTimeMocker.SetOneSecondAfter(DateTime.Now.AddDays(oneDay));
            SystemTimeMocker.Reset();

            SystemTime.Now.Should().BeCloseTo(DateTime.Now, acceptableInaccuracy);
        }
示例#2
0
        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;
                    }
                }
            }
        }
示例#3
0
        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();
                }
            }
        }
示例#4
0
 public static void AfterScenario()
 {
     SystemTimeMocker.Reset();
 }
示例#5
0
 public void Dispose()
 {
     SystemTimeMocker.Reset();
 }
示例#6
0
 public SystemTimeTests()
 {
     SystemTimeMocker.Reset();
 }