Exemple #1
0
        public void NoStartDateTimeRestrictionIsAppliedToMatches()
        {
            List <string> playerNames = new List <string>()
            {
                "Maru", "Stork", "Taeja", "Rain"
            };

            roundRobinRound.SetPlayersPerGroupCount(playerNames.Count);
            RoundRobinGroup roundRobinGroup = RegisterPlayers(playerNames);

            DateTime twoHoursLater    = SystemTime.Now.AddHours(2);
            DateTime oneHourLater     = SystemTime.Now.AddHours(1);
            DateTime fourHoursLater   = SystemTime.Now.AddHours(4);
            DateTime threeHoursLater  = SystemTime.Now.AddHours(3);
            DateTime twelveHoursLater = SystemTime.Now.AddHours(12);
            DateTime eightHoursLater  = SystemTime.Now.AddHours(8);

            roundRobinGroup.Matches[0].SetStartDateTime(twoHoursLater);
            roundRobinGroup.Matches[1].SetStartDateTime(oneHourLater);
            roundRobinGroup.Matches[2].SetStartDateTime(fourHoursLater);
            roundRobinGroup.Matches[3].SetStartDateTime(threeHoursLater);
            roundRobinGroup.Matches[4].SetStartDateTime(twelveHoursLater);
            roundRobinGroup.Matches[5].SetStartDateTime(eightHoursLater);

            roundRobinGroup.Matches[0].StartDateTime.Should().Be(twoHoursLater);
            roundRobinGroup.Matches[1].StartDateTime.Should().Be(oneHourLater);
            roundRobinGroup.Matches[2].StartDateTime.Should().Be(fourHoursLater);
            roundRobinGroup.Matches[3].StartDateTime.Should().Be(threeHoursLater);
            roundRobinGroup.Matches[4].StartDateTime.Should().Be(twelveHoursLater);
            roundRobinGroup.Matches[5].StartDateTime.Should().Be(eightHoursLater);

            tournamentIssueReporter.Issues.Should().BeEmpty();
        }
        public RoundRobinGroupLayoutAssemblerTests()
        {
            tournament      = Tournament.Create("GSL 2019");
            roundRobinRound = tournament.AddRoundRobinRound() as RoundRobinRound;
            roundRobinGroup = RoundRobinGroup.Create(roundRobinRound);

            playerReferences = new List <PlayerReference>();
            playerReferences.Add(PlayerReference.Create("Maru", tournament));
            playerReferences.Add(PlayerReference.Create("Stork", tournament));
            playerReferences.Add(PlayerReference.Create("Taeja", tournament));
            playerReferences.Add(PlayerReference.Create("Rain", tournament));
            playerReferences.Add(PlayerReference.Create("Bomber", tournament));
            playerReferences.Add(PlayerReference.Create("FanTaSy", tournament));
            playerReferences.Add(PlayerReference.Create("Stephano", tournament));
            playerReferences.Add(PlayerReference.Create("Thorzain", tournament));

            maruId     = playerReferences[0].Id;
            storkId    = playerReferences[1].Id;
            taejaId    = playerReferences[2].Id;
            rainId     = playerReferences[3].Id;
            bomberId   = playerReferences[4].Id;
            fantasyId  = playerReferences[5].Id;
            stephanoId = playerReferences[6].Id;
            thorzainId = playerReferences[7].Id;
        }
        void SetGroup(RoundRobinGroup group)
        {
            if (group == null)
            {
                throw new ArgumentNullException("group");
            }

            this.group = group;
        }
Exemple #4
0
        public void CanCreateGroup()
        {
            RoundRobinGroup roundRobinGroup = RoundRobinGroup.Create(roundRobinRound);

            roundRobinGroup.Should().NotBeNull();
            roundRobinGroup.Id.Should().NotBeEmpty();
            roundRobinGroup.Matches.Should().BeEmpty();
            roundRobinGroup.RoundId.Should().Be(roundRobinRound.Id);
            roundRobinGroup.Round.Should().Be(roundRobinRound);
        }
            //add a message filter to the MessageFilterTable
            public void Add(MessageFilter key, TFilterData value)
            {
                RoundRobinMessageFilter filter = (RoundRobinMessageFilter)key;
                RoundRobinGroup         group;

                if (!this.groups.TryGetValue(filter.groupName, out group))
                {
                    group = new RoundRobinGroup(filter.groupName);
                    this.groups.Add(filter.groupName, group);
                }
                group.AddFilter(filter);
                this.filters.Add(key, value);
            }
Exemple #6
0
        private void CreateSchedule(int groupId, IReadOnlyCollection <int> userIds)
        {
            DateTime date = _groupStageStartDate.Add(_currentSeason.IntervalBetweenRounds);
            RoundRobinGroup <int, Matchup <int> > roundRobinGroup =
                new RoundRobinGroup <int, Matchup <int> >(userIds);

            foreach (IRound <int, Matchup <int> > groupRound in roundRobinGroup)
            {
                _groupRoundService.Create(groupId, groupRound, date);
                date = date.Add(_currentSeason.IntervalBetweenRounds);
            }
            _roundsCount = roundRobinGroup.Count;
        }
Exemple #7
0
        public void MatchIsCreatedWhenTwoPlayerReferencesAreAddedToGroup()
        {
            string firstPlayerName  = "Maru";
            string secondPlayerName = "Stork";

            RoundRobinGroup roundRobinGroup = RegisterPlayers(new List <string>()
            {
                firstPlayerName, secondPlayerName
            });

            roundRobinGroup.Matches.Should().HaveCount(1);
            roundRobinGroup.Matches.FirstOrDefault(match => match.Player1.GetName() == firstPlayerName).Should().NotBeNull();
            roundRobinGroup.Matches.FirstOrDefault(match => match.Player2.GetName() == secondPlayerName).Should().NotBeNull();
        }
        public void Should_CreateRightRoundCount_When(int playerCount)
        {
            int expectedCount = playerCount;

            if (playerCount.IsEven())
            {
                expectedCount--;
            }

            RoundRobinGroup <int, Matchup <int> > roundRobinGroup =
                CreateRoundRobinGroup(playerCount);
            int actualCountPropertyValue = roundRobinGroup.Count;
            int actualCount = roundRobinGroup.Count();

            Assert.Equal(expectedCount, actualCountPropertyValue);
            Assert.Equal(expectedCount, actualCount);
        }
Exemple #9
0
        static void Main(string[] args)
        {
            // Create a new actor system (a container for your actors)
            var config = ConfigurationFactory.ParseString(SystemConfiguration.Config);
            var system = ActorSystem.Create("status-system", config);

            // Create your actor and get a reference (proxy) to it
            var actor = system.ActorOf <StatusActor>();

            // Create workers
            system.ActorOf <StatusActor>("status-1");
            system.ActorOf <StatusActor>("status-2");
            system.ActorOf <StatusActor>("status-3");
            system.ActorOf <StatusActor>("status-4");

            // Create the round robin router
            var routerConfig = new RoundRobinGroup("user/status-1", "user/status-2", "user/status-3", "user/status-4");
            var props        = new Props().WithRouter(routerConfig);
            var router       = system.ActorOf(props);

            // Save the actor handles
            var futures = new List <Task>();


            // Send a whole bunch of messages
            long[] messages = new long[] { 1, 10, 100, 1000, 10000, 100000 };
            long   sum      = 0;

            foreach (long i in messages)
            {
                sum += i;
                Stopwatch sw = Stopwatch.StartNew();
                for (long j = 0; j < i; j++)
                {
                    futures.Add(router.Ask <ActorStatusResponse>(new ActorStatusRequest()));
                }
                Console.WriteLine("Sent {0} messages in {1} seconds", messages, sw.ElapsedMilliseconds / 1000.0);
            }

            // Wait on the handles
            Stopwatch sw2 = Stopwatch.StartNew();

            futures.ForEach(_ => _.Wait());
            Console.WriteLine("Processed {0} messages in {1}", sum, sw2.ElapsedMilliseconds / 1000.0);
            Console.ReadKey();
        }
Exemple #10
0
        public PlayerInRoundRobinGroupTests()
        {
            tournament = Tournament.Create("GSL 2019");
            round      = tournament.AddRoundRobinRound();
            round.SetAdvancingPerGroupCount(1);
            round.SetPlayersPerGroupCount(4);

            foreach (string playerName in playerNames)
            {
                tournament.RegisterPlayerReference(playerName);
            }

            group = round.Groups.First() as RoundRobinGroup;
            match = group.Matches.First();
            match.SetBestOf(5);

            player = match.Player1;
        }
Exemple #11
0
        public void WhenTieInGroupIsSolvedByChoosing(int groupIndex, string commaSeparatedPlayerNames)
        {
            RoundRobinGroup        group            = createdGroups[groupIndex] as RoundRobinGroup;
            List <string>          playerNames      = StringUtility.ToStringList(commaSeparatedPlayerNames, ",");
            List <PlayerReference> playerReferences = new List <PlayerReference>();

            foreach (string playerName in playerNames)
            {
                foreach (Match match in group.Matches)
                {
                    Player player      = match.FindPlayer(playerName);
                    bool   playerFound = player != null;

                    if (playerFound)
                    {
                        group.SolveTieByChoosing(player.PlayerReferenceId);
                        break;
                    }
                }
            }
        }
        public void CanSerializeRoundRobinGroup()
        {
            var message = new RoundRobinGroup("abc");

            AssertEqual(message);
        }
Exemple #13
0
 protected override GroupBase AddGroup()
 {
     return(RoundRobinGroup.Create(this));
 }