public void ScoreboardPercentOnePlayer()
        {
            var handler = new AdvertiseMatchResult(serversTable, matchesTable, statisticsTable, new MockTimeGetter(new DateTime(51634312)));

            var data = new MockMatchData
            {
                ReturnValue = new MatchResults
                {
                    GameMode   = "DM",
                    Map        = "dedust",
                    Scoreboard = new List <PlayerScore>
                    {
                        new PlayerScore {
                            Name = "gold"
                        }
                    }
                }
            };


            handler.Process(new MatchParameters {
                Endpoint = "hostname-6556"
            }, data);

            Assert.AreEqual(1, statisticsTable.InsertCalledTimes);

            Assert.AreEqual(100, statisticsTable.InsertElements[0].AverageScoreboardPercent);
        }
        public void HandlerCall()
        {
            var timeGetter = new MockTimeGetter(new DateTime(51634312));
            var handler    = new AdvertiseMatchResult(serversTable, matchesTable, statisticsTable, timeGetter);

            var data = new MockMatchData
            {
                ReturnValue = new MatchResults
                {
                    FragLimit  = 20,
                    GameMode   = "DM",
                    Map        = "dedust",
                    Scoreboard = new List <PlayerScore>
                    {
                        new PlayerScore {
                            Name = "Existing"
                        },
                        new PlayerScore {
                            Name = "Not+Existing"
                        }
                    },
                    TimeElapsed = 12.2f,
                    TimeLimit   = 10
                }
            };

            handler.Process(new MatchParameters {
                Endpoint = "hostname-6556", Timestamp = timeGetter.Time
            }, data);

            // Assert inserted match:
            Assert.AreEqual(1, matchesTable.InsertCalledTimes);
            Assert.AreEqual("hostname-6556", matchesTable.InsertElements[0].Server);
            Assert.AreEqual(timeGetter.Time, matchesTable.InsertElements[0].Timestamp);
            Assert.AreEqual(data.ReturnValue, matchesTable.InsertElements[0].Results);

            // Assert updated server:
            Assert.AreEqual(1, serversTable.UpdateCalledTimes);
            Assert.AreEqual("hostname-6556", serversTable.UpdateElements[0].Endpoint);
            Assert.AreEqual(1, serversTable.UpdateElements[0].TotalMatchesPlayed);
            Assert.AreEqual(2, serversTable.UpdateElements[0].AveragePopulation);

            // Assert updated/inserted statistics:
            Assert.AreEqual(1, statisticsTable.UpdateCalledTimes);
            Assert.AreEqual(1, statisticsTable.InsertCalledTimes);
            Assert.AreEqual("Not+Existing", statisticsTable.InsertElements[0].DisplayName);
            Assert.AreEqual("Existing", statisticsTable.UpdateElements[0].DisplayName);
        }