public void TestShopListXmlGetAttributes() { string xml = @"<roar tick=""130695522924""> <shop> <list status=""ok""> <shopitem ikey=""shop_item_ikey_1"" label=""Shop item 1"" description=""Lorem Ipsum""> <costs> <stat_cost type=""currency"" ikey=""cash"" value=""100"" ok=""false"" reason=""Insufficient Coins""/> <stat_cost type=""currency"" ikey=""premium_currency"" value=""0"" ok=""true""/> </costs> <modifiers> <grant_item ikey=""item_ikey_1""/> </modifiers> <tags/> </shopitem> <shopitem ikey=""shop_item_ikey_2""/> <shopitem ikey=""some ikey"" label=""Shop item 2""/> <shopitem ikey=""blah blah"" description=""Blah Blah""> <costs> <stat_cost type=""currency"" ikey=""cash"" value=""0""/> <stat_cost type=""currency"" ikey=""premium_currency"" value=""50""/> </costs> <modifiers> <grant_item ikey=""item_ikey_2""/> </modifiers> <tags> <tag value=""a_tag""/> <tag value=""another_tag""/> </tags> </shopitem> </list> </shop> </roar>"; System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml); Roar.DataConversion.Responses.Shop.List converter = new Roar.DataConversion.Responses.Shop.List(); ListResponse response = converter.Build(nn); // Assume that costs, modifiers, requirements and tags conversions are tested someplace else // Hence we test only correct conversion from XML to ShopEntry on the higher level Assert.IsNotNull(response.shop_entries); Assert.AreEqual(response.shop_entries.Count, 4); Assert.AreEqual(response.shop_entries[0].ikey, "shop_item_ikey_1"); Assert.AreEqual(response.shop_entries[0].label, "Shop item 1"); Assert.AreEqual(response.shop_entries[0].description, "Lorem Ipsum"); Assert.AreEqual(response.shop_entries[0].costs.Count, 2); Assert.AreEqual(response.shop_entries[0].modifiers.Count, 1); Assert.AreEqual(response.shop_entries[0].requirements.Count, 0); Assert.AreEqual(response.shop_entries[0].tags.Count, 0); Assert.AreEqual(response.shop_entries[1].costs.Count, 0); Assert.AreEqual(response.shop_entries[1].modifiers.Count, 0); Assert.AreEqual(response.shop_entries[1].requirements.Count, 0); Assert.AreEqual(response.shop_entries[1].tags.Count, 0); Assert.AreEqual(response.shop_entries[3].ikey, "blah blah"); Assert.AreEqual(response.shop_entries[3].description, "Blah Blah"); }
public void TestShopListXmlGetAttributes() { string xml = @"<roar tick=""130695522924""> <shop> <list status=""ok""> <shopitem ikey=""shop_item_ikey_1"" label=""Shop item 1"" description=""Lorem Ipsum""> <costs> <stat_cost type=""currency"" ikey=""cash"" value=""100"" ok=""false"" reason=""Insufficient Coins""/> <stat_cost type=""currency"" ikey=""premium_currency"" value=""0"" ok=""true""/> </costs> <modifiers> <grant_item ikey=""item_ikey_1""/> </modifiers> <tags/> </shopitem> <shopitem ikey=""shop_item_ikey_2""/> <shopitem ikey=""some ikey"" label=""Shop item 2""/> <shopitem ikey=""blah blah"" description=""Blah Blah""> <costs> <stat_cost type=""currency"" ikey=""cash"" value=""0""/> <stat_cost type=""currency"" ikey=""premium_currency"" value=""50""/> </costs> <modifiers> <grant_item ikey=""item_ikey_2""/> </modifiers> <tags> <tag value=""a_tag""/> <tag value=""another_tag""/> </tags> </shopitem> </list> </shop> </roar>" ; System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml); Roar.DataConversion.Responses.Shop.List converter = new Roar.DataConversion.Responses.Shop.List(); ListResponse response = converter.Build(nn); // Assume that costs, modifiers, requirements and tags conversions are tested someplace else // Hence we test only correct conversion from XML to ShopEntry on the higher level Assert.IsNotNull(response.shop_entries); Assert.AreEqual(response.shop_entries.Count, 4); Assert.AreEqual(response.shop_entries[0].ikey, "shop_item_ikey_1"); Assert.AreEqual(response.shop_entries[0].label, "Shop item 1"); Assert.AreEqual(response.shop_entries[0].description, "Lorem Ipsum"); Assert.AreEqual(response.shop_entries[0].costs.Count, 2); Assert.AreEqual(response.shop_entries[0].modifiers.Count, 1); Assert.AreEqual(response.shop_entries[0].requirements.Count, 0); Assert.AreEqual(response.shop_entries[0].tags.Count, 0); Assert.AreEqual(response.shop_entries[1].costs.Count, 0); Assert.AreEqual(response.shop_entries[1].modifiers.Count, 0); Assert.AreEqual(response.shop_entries[1].requirements.Count, 0); Assert.AreEqual(response.shop_entries[1].tags.Count, 0); Assert.AreEqual(response.shop_entries[3].ikey, "blah blah"); Assert.AreEqual(response.shop_entries[3].description, "Blah Blah"); }
public void TestListShopXmlParsesCorrectly() { string xml = @"<roar tick=""135562028150""> <shop> <list status=""ok""> <shopitem ikey=""rocket_fuel"" label=""Rocket Fuel"" description=""""> <costs> <stat_cost type=""currency"" ikey=""gamecoins"" value=""10"" ok=""true""/> </costs> <modifiers> <grant_stat type=""currency"" ikey=""rocket_fuel"" value=""100""/> </modifiers> <tags/> </shopitem> <shopitem ikey=""neil_armstrong"" label=""Neil Armstrong"" description=""Best copilot in the world""> <costs> <stat_cost type=""currency"" ikey=""premium_currency"" value=""15"" ok=""false"" reason=""Insufficient Premium Currency""/> </costs> <modifiers> <grant_item ikey=""npc_armstrong""/> </modifiers> <tags> <tag value=""copilot""/> </tags> </shopitem> <shopitem ikey=""starter_space_pack"" label=""Starter Space Pack"" description=""Get going!""> <costs> <stat_cost type=""currency"" ikey=""gamecoins"" value=""20"" ok=""true""/> </costs> <modifiers> <grant_stat type=""currency"" ikey=""rocket_fuel"" value=""30""/> <grant_item ikey=""regular_space_helmet""/> <grant_item ikey=""rocket_ship""/> </modifiers> <tags> <tag value=""pack""/> </tags> </shopitem> </list> </shop> </roar>"; System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml); Assert.IsNotNull( nn ); System.Xml.XmlNode c1 = nn.SelectSingleNode("./shop/list/shopitem[1]/costs"); System.Xml.XmlNode c2 = nn.SelectSingleNode("./shop/list/shopitem[2]/costs"); System.Xml.XmlNode c3 = nn.SelectSingleNode("./shop/list/shopitem[3]/costs"); Assert.IsNotNull (c1); Assert.IsNotNull (c2); Assert.IsNotNull (c3); IList<Roar.DomainObjects.Cost> cl1 = new List<Roar.DomainObjects.Cost>(); IList<Roar.DomainObjects.Cost> cl2 = new List<Roar.DomainObjects.Cost>(); IList<Roar.DomainObjects.Cost> cl3 = new List<Roar.DomainObjects.Cost>(); System.Xml.XmlNode m1 = nn.SelectSingleNode("./shop/list/shopitem[1]/modifiers"); System.Xml.XmlNode m2 = nn.SelectSingleNode("./shop/list/shopitem[2]/modifiers"); System.Xml.XmlNode m3 = nn.SelectSingleNode("./shop/list/shopitem[3]/modifiers"); Assert.IsNotNull (m1); Assert.IsNotNull (m2); Assert.IsNotNull (m3); IList<Roar.DomainObjects.Modifier> ml1 = new List<Roar.DomainObjects.Modifier>(); IList<Roar.DomainObjects.Modifier> ml2 = new List<Roar.DomainObjects.Modifier>(); IList<Roar.DomainObjects.Modifier> ml3 = new List<Roar.DomainObjects.Modifier>(); Mockery mockery = new Mockery(); Roar.DataConversion.IXCRMParser ixcrm_parser = mockery.NewMock<Roar.DataConversion.IXCRMParser>(); Expect.Once.On(ixcrm_parser).Method("ParseCostList").With( c1 ).Will( Return.Value( cl1 ) ); Expect.Once.On(ixcrm_parser).Method("ParseCostList").With( c2 ).Will( Return.Value( cl2 ) ); Expect.Once.On(ixcrm_parser).Method("ParseCostList").With( c3 ).Will( Return.Value( cl3 ) ); Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With( m1 ).Will( Return.Value( ml1 ) ); Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With( m2 ).Will( Return.Value( ml2 ) ); Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With( m3 ).Will( Return.Value( ml3 ) ); Roar.DataConversion.Responses.Shop.List shoplist_response_parser = new Roar.DataConversion.Responses.Shop.List(); shoplist_response_parser.ixcrm_parser = ixcrm_parser; Roar.WebObjects.Shop.ListResponse response = shoplist_response_parser.Build(nn); Assert.IsNotNull(response); mockery.VerifyAllExpectationsHaveBeenMet(); }
public void TestListShopXmlParsesCorrectly_System() { string xml = @"<roar tick=""135562028150""> <shop> <list status=""ok""> <shopitem ikey=""rocket_fuel"" label=""Rocket Fuel"" description=""""> <costs> <stat_cost type=""currency"" ikey=""gamecoins"" value=""10"" ok=""true""/> </costs> <modifiers> <grant_stat type=""currency"" ikey=""rocket_fuel"" value=""100""/> </modifiers> <tags/> </shopitem> <shopitem ikey=""neil_armstrong"" label=""Neil Armstrong"" description=""Best copilot in the world""> <costs> <stat_cost type=""currency"" ikey=""premium_currency"" value=""15"" ok=""false"" reason=""Insufficient Premium Currency""/> </costs> <modifiers> <grant_item ikey=""npc_armstrong""/> </modifiers> <tags> <tag value=""copilot""/> </tags> </shopitem> <shopitem ikey=""starter_space_pack"" label=""Starter Space Pack"" description=""Get going!""> <costs> <stat_cost type=""currency"" ikey=""gamecoins"" value=""20"" ok=""true""/> </costs> <modifiers> <grant_stat type=""currency"" ikey=""rocket_fuel"" value=""30""/> <grant_item ikey=""regular_space_helmet""/> <grant_item ikey=""rocket_ship""/> </modifiers> <tags> <tag value=""pack""/> </tags> </shopitem> </list> </shop> </roar>" ; System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml); Assert.IsNotNull(nn); System.Xml.XmlNode c1 = nn.SelectSingleNode("./shop/list/shopitem[1]/costs"); System.Xml.XmlNode c2 = nn.SelectSingleNode("./shop/list/shopitem[2]/costs"); System.Xml.XmlNode c3 = nn.SelectSingleNode("./shop/list/shopitem[3]/costs"); Assert.IsNotNull(c1); Assert.IsNotNull(c2); Assert.IsNotNull(c3); Assert.AreEqual("gamecoins", (c1.SelectSingleNode("./stat_cost") as System.Xml.XmlElement).GetAttribute("ikey")); Assert.AreEqual("premium_currency", (c2.SelectSingleNode("./stat_cost") as System.Xml.XmlElement).GetAttribute("ikey")); Assert.AreEqual("gamecoins", (c3.SelectSingleNode("./stat_cost") as System.Xml.XmlElement).GetAttribute("ikey")); IList <Roar.DomainObjects.Cost> cl1 = new List <Roar.DomainObjects.Cost>(); IList <Roar.DomainObjects.Cost> cl2 = new List <Roar.DomainObjects.Cost>(); IList <Roar.DomainObjects.Cost> cl3 = new List <Roar.DomainObjects.Cost>(); System.Xml.XmlNode m1 = nn.SelectSingleNode("./shop/list/shopitem[1]/modifiers"); System.Xml.XmlNode m2 = nn.SelectSingleNode("./shop/list/shopitem[2]/modifiers"); System.Xml.XmlNode m3 = nn.SelectSingleNode("./shop/list/shopitem[3]/modifiers"); Assert.IsNotNull(m1); Assert.IsNotNull(m2); Assert.IsNotNull(m3); IList <Roar.DomainObjects.Modifier> ml1 = new List <Roar.DomainObjects.Modifier>(); IList <Roar.DomainObjects.Modifier> ml2 = new List <Roar.DomainObjects.Modifier>(); IList <Roar.DomainObjects.Modifier> ml3 = new List <Roar.DomainObjects.Modifier>(); Mockery mockery = new Mockery(); Roar.DataConversion.IXCRMParser ixcrm_parser = mockery.NewMock <Roar.DataConversion.IXCRMParser>(); Expect.Once.On(ixcrm_parser).Method("ParseCostList").With(new SystemXmlMatcher(c1 as System.Xml.XmlElement)).Will(Return.Value(cl1)); Expect.Once.On(ixcrm_parser).Method("ParseCostList").With(new SystemXmlMatcher(c2 as System.Xml.XmlElement)).Will(Return.Value(cl2)); Expect.Once.On(ixcrm_parser).Method("ParseCostList").With(new SystemXmlMatcher(c3 as System.Xml.XmlElement)).Will(Return.Value(cl3)); Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(new SystemXmlMatcher(m1 as System.Xml.XmlElement)).Will(Return.Value(ml1)); Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(new SystemXmlMatcher(m2 as System.Xml.XmlElement)).Will(Return.Value(ml2)); Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(new SystemXmlMatcher(m3 as System.Xml.XmlElement)).Will(Return.Value(ml3)); Roar.DataConversion.Responses.Shop.List shoplist_response_parser = new Roar.DataConversion.Responses.Shop.List(); shoplist_response_parser.ixcrm_parser = ixcrm_parser; Roar.WebObjects.Shop.ListResponse response = shoplist_response_parser.Build(nn); Assert.IsNotNull(response); mockery.VerifyAllExpectationsHaveBeenMet(); }