Exemplo n.º 1
0
        public void MenuDelete_Ok()
        {
            var menu = MenuHelper.RetrieveMenus("Admin").FirstOrDefault(m => m.Category == "0");

            Assert.True(MenuHelper.Delete(new string[] { menu.Id }));
            var menu2 = MenuHelper.RetrieveMenus("Admin").FirstOrDefault(m => m.Id == menu.Id);

            Assert.NotNull(menu2);

            // 保护模式下,正常選單可以刪除
            var poco = new BootstrapMenu()
            {
                Name        = "UnitTest",
                Application = "3",
                Category    = "1",
                Icon        = "fa fa-fa",
                IsResource  = 0,
                Target      = "_blank",
                Order       = 10,
                Url         = "#",
                ParentId    = "0",
                ParentName  = "Test",
            };

            // insert
            Assert.True(MenuHelper.Save(poco));

            // update
            poco = MenuHelper.RetrieveAllMenus("Admin").Where(m => m.Id == poco.Id).FirstOrDefault();
            Assert.True(MenuHelper.Save(poco));

            // clean
            MenuHelper.Delete(new string[] { poco.Id });
        }
Exemplo n.º 2
0
        public void MenuSave_Ok()
        {
            var menu = MenuHelper.RetrieveMenus("Admin").FirstOrDefault(m => m.Category == "0");
            var name = menu.Name;

            menu.Name = "UnitTest";
            Assert.True(MenuHelper.Save(menu));

            var menu2 = MenuHelper.RetrieveMenus("Admin").FirstOrDefault(m => m.Id == menu.Id);

            Assert.Equal(name, menu2.Name);
        }