Esempio n. 1
0
        public void OMF_ToXML_ValidXML()
        {
            var mi1 = new MenuItem {UID = "1", Description = "desc1", Name = "item1"};
              var mi2 = new MenuItem {UID = "2", Description = "desc2", Name = "item2"};

              var mg1 = new MenuGroup {UID = "1", Description = "desc", Name = "myname", Items = new ObservableCollection<MenuItem> {mi1, mi2}};
              var mg2 = new MenuGroup {UID = "2", Description = "desc", Name = "myname", Items = new ObservableCollection<MenuItem> {mi1, mi2}};

              var m = new Menu {UID = "1", Name = "alacarte", Description = "desc", Currency = "EUR", Groups = new ObservableCollection<MenuGroup> {mg1, mg2}};

              var omf = new OpenMenuFormat {UUID = "74c2b466-e360-42f0-9060-9cc7765e196a", Menus = new ObservableCollection<Menu> {m}};
              string xml = omf.ToXML().ToString();
              Assert.AreEqual("<omf uuid=\"74c2b466-e360-42f0-9060-9cc7765e196a\">\r\n  <menus>\r\n    <menu uid=\"1\" name=\"alacarte\" currency_symbol=\"EUR\">\r\n      <menu_description>desc</menu_description>\r\n      <menu_groups>\r\n        <menu_group uid=\"1\" name=\"myname\">\r\n          <menu_group_description>desc</menu_group_description>\r\n          <menu_items>\r\n            <menu_item uid=\"1\">\r\n              <menu_item_name>item1</menu_item_name>\r\n              <menu_item_description>desc1</menu_item_description>\r\n              <menu_item_price>0</menu_item_price>\r\n            </menu_item>\r\n            <menu_item uid=\"2\">\r\n              <menu_item_name>item2</menu_item_name>\r\n              <menu_item_description>desc2</menu_item_description>\r\n              <menu_item_price>0</menu_item_price>\r\n            </menu_item>\r\n          </menu_items>\r\n        </menu_group>\r\n        <menu_group uid=\"2\" name=\"myname\">\r\n          <menu_group_description>desc</menu_group_description>\r\n          <menu_items>\r\n            <menu_item uid=\"1\">\r\n              <menu_item_name>item1</menu_item_name>\r\n              <menu_item_description>desc1</menu_item_description>\r\n              <menu_item_price>0</menu_item_price>\r\n            </menu_item>\r\n            <menu_item uid=\"2\">\r\n              <menu_item_name>item2</menu_item_name>\r\n              <menu_item_description>desc2</menu_item_description>\r\n              <menu_item_price>0</menu_item_price>\r\n            </menu_item>\r\n          </menu_items>\r\n        </menu_group>\r\n      </menu_groups>\r\n    </menu>\r\n  </menus>\r\n</omf>", xml);
        }
Esempio n. 2
0
 public void OMF_FromRealXML_ValidObject()
 {
     var mi = new OpenMenuFormat();
       string xmlIn = Properties.Resources.alacarte_menu;
       XElement xmlElem = XElement.Load(new StringReader(xmlIn));
       mi.FromXML(xmlElem);
       Assert.AreEqual("df8cb20e-297c-11e0-91d7-0018512e6b26", mi.UUID);
       Assert.AreEqual(1, mi.Menus.Count);
       foreach (Menu menu in mi.Menus) {
     Assert.AreEqual(3, menu.Groups.Count);
     foreach (MenuGroup menuGroup in menu.Groups) {
       Assert.AreEqual(1, menuGroup.Items.Count);
     }
       }
 }
Esempio n. 3
0
 public void OMF_FromXML_ValidObject()
 {
     var mi = new OpenMenuFormat();
       string xmlIn = "<omf uuid=\"74c2b466-e360-42f0-9060-9cc7765e196a\">\r\n  <menus>\r\n    <menu uid=\"1\" name=\"alacarte\" currency_symbol=\"EUR\">\r\n      <menu_description>desc</menu_description>\r\n      <menu_groups>\r\n        <menu_group uid=\"1\" name=\"myname\">\r\n          <menu_group_description>desc</menu_group_description>\r\n          <menu_items>\r\n            <menu_item uid=\"1\">\r\n              <menu_item_name>item1</menu_item_name>\r\n              <menu_item_description>desc1</menu_item_description>\r\n              <menu_item_price>0</menu_item_price>\r\n            </menu_item>\r\n            <menu_item uid=\"2\">\r\n              <menu_item_name>item2</menu_item_name>\r\n              <menu_item_description>desc2</menu_item_description>\r\n              <menu_item_price>0</menu_item_price>\r\n            </menu_item>\r\n          </menu_items>\r\n        </menu_group>\r\n        <menu_group uid=\"2\" name=\"myname\">\r\n          <menu_group_description>desc</menu_group_description>\r\n          <menu_items>\r\n            <menu_item uid=\"1\">\r\n              <menu_item_name>item1</menu_item_name>\r\n              <menu_item_description>desc1</menu_item_description>\r\n              <menu_item_price>0</menu_item_price>\r\n            </menu_item>\r\n            <menu_item uid=\"2\">\r\n              <menu_item_name>item2</menu_item_name>\r\n              <menu_item_description>desc2</menu_item_description>\r\n              <menu_item_price>0</menu_item_price>\r\n            </menu_item>\r\n          </menu_items>\r\n        </menu_group>\r\n      </menu_groups>\r\n    </menu>\r\n  </menus>\r\n</omf>";
       XElement xmlElem = XElement.Load(new StringReader(xmlIn));
       mi.FromXML(xmlElem);
       Assert.AreEqual("74c2b466-e360-42f0-9060-9cc7765e196a", mi.UUID);
       Assert.AreEqual(1, mi.Menus.Count);
       foreach (Menu menu in mi.Menus) {
     Assert.AreEqual(2, menu.Groups.Count);
     foreach (MenuGroup menuGroup in menu.Groups) {
       Assert.AreEqual(2, menuGroup.Items.Count);
     }
       }
 }