示例#1
0
        public void TestGoogleFriendsXmlGetAttributes()
        {
            string xml =
                @"<roar tick=""128455369786"">
				<google>
					<friends status=""ok"">
						<!-- ""Mashton"" is already playing this game and has an 'id' we can use -->
						<friend gplus_name=""Mashton Groober"" gplus_id=""51151277315"" name=""Mashton"" id=""7877788777""/>
						<!-- These other two friends are not playing this game (no 'id' or 'name') -->
						<friend gplus_name=""Jumpy Maxton"" gplus_id=""529465555""/>
						<friend gplus_name=""Ami Jones"" gplus_id=""523055555""/>
					</friends>
				</google>
			</roar>"            ;

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);
            Roar.DataConversion.Responses.Google.Friends friends_parser = new Roar.DataConversion.Responses.Google.Friends();
            FriendsResponse response = friends_parser.Build(nn);

            Assert.AreEqual(response.friends.Count, 3);
            Assert.AreEqual(response.friends[0].id, "7877788777");
            Assert.AreEqual(response.friends[0].name, "Mashton");
            Assert.AreEqual(response.friends[0].gplus_id, "51151277315");
            Assert.AreEqual(response.friends[0].gplus_name, "Mashton Groober");
            Assert.IsNull(response.friends[1].id);
            Assert.IsNull(response.friends[1].name);
            Assert.AreEqual(response.friends[1].gplus_id, "529465555");
            Assert.AreEqual(response.friends[1].gplus_name, "Jumpy Maxton");
            Assert.IsNull(response.friends[2].id);
            Assert.IsNull(response.friends[2].name);
            Assert.AreEqual(response.friends[2].gplus_id, "523055555");
            Assert.AreEqual(response.friends[2].gplus_name, "Ami Jones");
        }
        public void TestGoogleFriendsXmlGetAttributes()
        {
            string xml =
            @"<roar tick=""128455369786"">
                <google>
                    <friends status=""ok"">
                        <!-- ""Mashton"" is already playing this game and has an 'id' we can use -->
                        <friend gplus_name=""Mashton Groober"" gplus_id=""51151277315"" name=""Mashton"" id=""7877788777""/>
                        <!-- These other two friends are not playing this game (no 'id' or 'name') -->
                        <friend gplus_name=""Jumpy Maxton"" gplus_id=""529465555""/>
                        <friend gplus_name=""Ami Jones"" gplus_id=""523055555""/>
                    </friends>
                </google>
            </roar>";

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);
            Roar.DataConversion.Responses.Google.Friends friends_parser = new Roar.DataConversion.Responses.Google.Friends();
            FriendsResponse response = friends_parser.Build(nn);

            Assert.AreEqual(response.friends.Count, 3);
            Assert.AreEqual(response.friends[0].id, "7877788777");
            Assert.AreEqual(response.friends[0].name, "Mashton");
            Assert.AreEqual(response.friends[0].gplus_id, "51151277315");
            Assert.AreEqual(response.friends[0].gplus_name, "Mashton Groober");
            Assert.IsNull(response.friends[1].id);
            Assert.IsNull(response.friends[1].name);
            Assert.AreEqual(response.friends[1].gplus_id, "529465555");
            Assert.AreEqual(response.friends[1].gplus_name, "Jumpy Maxton");
            Assert.IsNull(response.friends[2].id);
            Assert.IsNull(response.friends[2].name);
            Assert.AreEqual(response.friends[2].gplus_id, "523055555");
            Assert.AreEqual(response.friends[2].gplus_name, "Ami Jones");
        }