Esempio n. 1
0
        public void GetRecentMatches()
        {
            var db        = new DataBase("testdb.db", true);
            var inputData = new ServerInfo {
                name = "MyServer001", gameModes = new string[] { "DM" }
            };

            db.PutInfo("server1", JsonConvert.SerializeObject(inputData));

            string matchData1 = MatchGenerator.GetMatch();
            string matchData2 = MatchGenerator.GetMatch();
            string matchData3 = MatchGenerator.GetMatch();

            db.PutMatch("server1", "2017-01-22T15:14:00Z", matchData3);
            db.PutMatch("server1", "2017-01-22T15:17:00Z", matchData1);
            db.PutMatch("server1", "2017-01-22T15:16:00Z", matchData2);

            var recentMatches = db.GetRecentMatches(5);
            var excepted      = "[" + matchData1 + "," + matchData2 + "," + matchData3 + "]";

            Assert.AreEqual(
                excepted,
                recentMatches
                );
        }
Esempio n. 2
0
        public void GetPopularServers()
        {
            var db        = new DataBase("testdb.db", true);
            var inputData = new ServerInfo {
                name = "MyServer001", gameModes = new string[] { "DM" }
            };
            var inputData2 = new ServerInfo {
                name = "MyServer002", gameModes = new string[] { "DM" }
            };

            db.PutInfo("server1", JsonConvert.SerializeObject(inputData));
            db.PutInfo("server2", JsonConvert.SerializeObject(inputData2));

            string matchData1 = MatchGenerator.GetMatch();
            string matchData2 = MatchGenerator.GetMatch();
            string matchData3 = MatchGenerator.GetMatch();

            db.PutMatch("server1", "2017-01-22T15:14:00Z", matchData3);
            db.PutMatch("server1", "2017-01-22T15:17:00Z", matchData1);
            db.PutMatch("server2", "2017-01-22T15:16:00Z", matchData2);

            var popularServers = db.GetPopularServers(5);
            var excepted       = JsonConvert.SerializeObject(new object[] {
                new{
                    endpoint             = "server1",
                    name                 = "MyServer001",
                    averageMatchesPerDay = 2.0
                },
                new {
                    endpoint             = "server2",
                    name                 = "MyServer002",
                    averageMatchesPerDay = 1.0
                }
            });

            Assert.AreEqual(
                excepted,
                popularServers
                );
        }