Пример #1
0
        public void testCsgoStatus()
        {
            string test = "hostname: long hostname\n" +
                          "version: 1.37.4.4 / 13744 1081 / 7776 secure[G: 1:3091169]\n" +
                          "udp / ip  : 127.0.0.1:27711(public ip: 1.1.1.1)\n" +
                          "os      :  Linux\n" +
                          "type    :  community dedicated\n" +
                          "map     : de_dust2\n" +
                          "gotv[0]:  port 27712, delay 90.0s, rate 32.0\n" +
                          "players : 2 humans, 1 bots(6/0 max) (not hibernating)\n\n" +
                          "# userid name uniqueid connected ping loss state rate adr\n" +
                          "# 2 \"GOTV\" BOT active 32\n";
            StatusParser parser = new StatusParser();

            Assert.IsTrue(parser.IsMatch(test));
            Status status = parser.Parse(test);

            Assert.IsFalse(status.Hibernating);
            Assert.AreEqual("1.1.1.1", status.PublicHost);
            Assert.AreEqual("127.0.0.1:27711", status.LocalHost);
            Assert.AreEqual("long hostname", status.Hostname);
            Assert.AreEqual("de_dust2", status.Map);
            Assert.AreEqual(2, status.Humans);
            Assert.AreEqual(6, status.MaxPlayers);
            Assert.AreEqual(1, status.Bots);
        }
Пример #2
0
        public void testHibernatingStatus()
        {
            string       test   = "Server hibernating";
            StatusParser parser = new StatusParser();

            Assert.IsTrue(parser.IsMatch(test));
            Status status = parser.Parse(test);

            Assert.IsTrue(status.Hibernating);
        }
Пример #3
0
        public void testL4DStatus()
        {
            string test = "hostname: l4d hostname\n" +
                          "version: 2019.11.12 / 24 7671 secure\n" +
                          "udp / ip  : (127.0.0.1:1234)  (public ip: 1.1.1.1)\n" +
                          "map     : deathrun_portal at: 0 x, 0 y, 0 z\n" +
                          "players : 5 (24 max)\n" +
                          "# userid name                uniqueid            connected ping loss state  adr\n" +
                          "id id id";
            StatusParser parser = new StatusParser();

            Assert.IsTrue(parser.IsMatch(test));
            Status status = parser.Parse(test);

            Assert.IsFalse(status.Hibernating);
            Assert.AreEqual("1.1.1.1", status.PublicHost);
            Assert.AreEqual("127.0.0.1:1234", status.LocalHost);
            Assert.AreEqual("l4d hostname", status.Hostname);
            Assert.AreEqual("deathrun_portal at: 0 x, 0 y, 0 z", status.Map);
            Assert.AreEqual(5, status.Humans);
            Assert.AreEqual(24, status.MaxPlayers);
        }