Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        private void UpdateStatus()
        {
            if (this.associatedObject == null)
            {
                return;
            }

            var formattedString = new FormattedString();
            var inlines         = formattedString.Spans;

            var parser    = new StatusParser();
            var tootSpans = parser.Parse(this.Status);

            foreach (var tootSpan in tootSpans)
            {
                var span = new Span {
                    Text = tootSpan.Text
                };
                switch (tootSpan.Type)
                {
                case TootSpan.SpanType.Text:
                    // 絵文字変換を忘れない
                    span.Text = (string)_emojiConverter.Convert(tootSpan.Text, typeof(string), null, (System.Globalization.CultureInfo)null);
                    inlines.Add(span);
                    break;

                case TootSpan.SpanType.HyperLink:
                    span.ForegroundColor = Color.Blue;
                    inlines.Add(span);
                    break;

                case TootSpan.SpanType.Tag:
                    span.ForegroundColor = Color.Blue;
                    inlines.Add(span);
                    break;

                case TootSpan.SpanType.LineBreak:
                    span.Text = Environment.NewLine;
                    inlines.Add(span);
                    break;

                default:
                    break;
                }
            }

            this.associatedObject.FormattedText = formattedString;

            // ついでに表示非表示を決める
            this.associatedObject.IsVisible = true; // inlines.Count > 0;
        }
Exemplo n.º 4
0
        public void EnsurePositionCanBeCorrectlyParsedFromXml()
        {
            var statusFile = TestUtilities.GetTestFile("status.xml");
            var statusXml  = File.ReadAllText(statusFile.FullName);

            var statusSource = MockRepository.GenerateMock <IVlcStatusSource>();

            statusSource.Expect(x => x.GetXml()).Return(statusXml);

            var parser = new StatusParser
            {
                Xml = statusXml
            };

            parser.Parse();
            Assert.AreEqual(0.01635168120265, parser.Position);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public async Task GetStatus(string tobeParsedString)
        {
            try
            {
                IsLoading = true;
                IsError   = false;

                var ResultList = await StatusParser.Parse(tobeParsedString);

                foreach (var s in ResultList)
                {
                    StatusCollection.Add(s);
                }
                if (StatusCollection.Count == 0)
                {
                    IsError = true;
                }
            }
            catch
            {
                IsError = true;
            }
            IsLoading = false;
        }