예제 #1
0
 public void TestICollectionMembersOnMenuList()
 {
     MenuList list = new MenuList();
     var item = new MenuItem();
     list.Add(item);
     Assert.IsTrue(list.Contains(item));
     list.Remove(item);
     Assert.IsFalse(list.Contains(item));
     list.Add(item);
     Assert.AreEqual(1, list.Count);
     list.Clear();
     Assert.AreEqual(0, list.Count);
     MenuItem[] array = new MenuItem[1];
     list.Add(item);
     list.CopyTo(array, 0);
     Assert.AreEqual(item, array[0]);
     Assert.IsFalse(list.IsReadOnly);
     foreach (var menuItem in list)
     {
         Assert.AreEqual(item, menuItem);
     }
 }
예제 #2
0
        public void MenuItem_Fluent_Tests()
        {
            MenuItem item = new MenuItem();
            item.SetTitle("Title").SetIcon("Icon").SetHelpText("Help").SetActionUrl("Action").SetAnchorClass("AnchorClass").
                SetIconClass("IconClass").SetItemClass("ItemClass");

            Assert.AreEqual("Title", item.Title);
            Assert.AreEqual("Icon", item.Icon);
            Assert.AreEqual("Help", item.HelpText);
            Assert.AreEqual("Action", item.ActionUrl);
            Assert.AreEqual("AnchorClass", item.AnchorClass);
            Assert.AreEqual("IconClass", item.IconClass);
            Assert.AreEqual("ItemClass", item.ItemClass);

            MenuList list = new MenuList();
            list.SetListClass("ListClass");
            Assert.AreEqual("ListClass", list.ListClass);

            ActionMenuItem<HomeController> ai = new ActionMenuItem<HomeController>();
            ai.SetMenuAction(p => p.Index());
            Assert.AreEqual("p.Index()", ai.MenuAction.Body.ToString());
        }