コード例 #1
0
        public void MenuGroup_ToXML_ValidXML()
        {
            var mi1 = new MenuItem {UID = "1", Description = "desc1", Name = "item1"};
              var mi2 = new MenuItem {UID = "2", Description = "desc2", Name = "item2"};

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

              string xml = mg.ToXML().ToString();
              Assert.AreEqual("<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>", xml);
        }
コード例 #2
0
        public void Menu_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}};
              string xml = m.ToXML().ToString();
              Assert.AreEqual("<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>", xml);
        }
コード例 #3
0
 public void MenuItem_FromXML_ValidObject()
 {
     var mi = new MenuItem();
       string xmlIn = "<menu_item uid=\"1\" disabled=\"disabled\" special=\"special\">\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>";
       XElement xmlElem = XElement.Load(new StringReader(xmlIn));
       mi.FromXML(xmlElem);
       Assert.AreEqual("item1", mi.Name);
       Assert.AreEqual("desc1", mi.Description);
       Assert.AreEqual(0d, mi.Price);
       Assert.IsTrue(mi.Disabled);
       Assert.IsTrue(mi.Special);
       Assert.IsFalse(mi.Vegetarian);
 }
コード例 #4
0
ファイル: MenuGroup.cs プロジェクト: dotob/OpenMenuEditor
        public override void FromXML(XElement xml)
        {
            this.Name = (string) xml.Attribute("name");
              this.Description = (string)xml.Element("menu_group_description");
              this.UID = (string)xml.Attribute("uid");

              XElement itemsElement = xml.Element("menu_items");
              if (itemsElement != null) {
            this.Items = new ObservableCollection<MenuItem>();
            foreach (XElement itemElement in itemsElement.Elements()) {
              var mi = new MenuItem();
              mi.Group = this;
              mi.FromXML(itemElement);
              this.Items.Add(mi);
            }
              }
        }
コード例 #5
0
 public void MenuItem_ToXML_ValidXML()
 {
     var mi1 = new MenuItem {UID = "1", Description = "desc1", Name = "item1"};
       string xml = mi1.ToXML().ToString();
       Assert.AreEqual("<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>", xml);
 }
コード例 #6
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);
        }