Beispiel #1
0
 public void HandleMessages()
 {
     while (!_shouldClose)
     {
         string msg = string.Empty;
         msg = _handler.TryGetMsgReceived();
         if (msg != null)
         {
             var parsedMsg = _xmlParser.ParseString(msg, true);
             parsedMsg.ForEach(p =>
             {
                 if (p != null)
                 {
                     p.Handle(this);
                 }
             });
         }
     }
 }
Beispiel #2
0
        public void ParseLeaderboarrdRespTestGood()
        {
            LeaderboardCommMessage     lbcm = new LeaderboardCommMessage(1, -1, LeaderboardCommMessage.SortingOption.HighestCashGain);
            List <LeaderboardLineData> data = new List <LeaderboardLineData>
            {
                new LeaderboardLineData(1, "Oded", 100, 1000, 13, 12),
                new LeaderboardLineData(1, "Jordy", 1000, 10, 130, 11)
            };
            LeaderboardResponseCommMessage response = new LeaderboardResponseCommMessage(1, -1,
                                                                                         true, lbcm, data);
            string msgStr =
                "r{\"?xml\":{\"@version\":\"1.0\",\"@encoding\":\"utf-16\"}," +
                "\"LeaderboardResponseCommMessage\":{\"@xmlns:xsd\":\"http://www.w3.org/2001/XMLSchema\"," +
                "\"@xmlns:xsi\":\"http://www.w3.org/2001/XMLSchema-instance\",\"UserId\":\"1\",\"Success\":\"true\"," +
                "\"OriginalMsg\":{\"@xsi:type\":\"LeaderboardCommMessage\",\"UserId\":\"1\",\"SortedBy\":\"HighestCashGain\"}," +
                "\"Results\":{\"LeaderboardLineData\":[{\"Id\":\"1\",\"Name\":\"Oded\",\"Points\":\"100\",\"TotalGrossProfit\":" +
                "\"1000\",\"HighestCashGain\":\"13\",\"NumOfGamesPlayed\":\"12\"},{\"Id\":\"1\",\"Name\":\"Jordy\",\"Points\":" +
                "\"1000\",\"TotalGrossProfit\":\"10\",\"HighestCashGain\":\"130\",\"NumOfGamesPlayed\":\"11\"}]}}}";
            var parsed = _parser.ParseString(_parser.JsonToXml(msgStr), false);

            Assert.AreEqual(1, parsed.Count);
            Assert.True(response.Equals(parsed[0]));
        }