Esempio n. 1
0
        public int CompareTo(object obj)
        {
            MenuMock menu = obj as MenuMock;

            if (OrderId > menu.OrderId)
            {
                return(-1);
            }
            if (OrderId < menu.OrderId)
            {
                return(1);
            }
            if (base.Id > menu.Id)
            {
                return(1);
            }
            if (base.Id < menu.Id)
            {
                return(-1);
            }
            return(0);
        }
Esempio n. 2
0
        public void testMenuParentId()
        {
            List <MenuMock> oldList = cdb.findAll <MenuMock>();

            foreach (MenuMock menuMock in oldList)
            {
                menuMock.delete();
            }

            for (int i = 0; i < 20; i++)
            {
                MenuMock menu = new MenuMock();
                menu.Name = "menu" + i;
                menu.insert();
            }


            for (int i = 0; i < 20; i++)
            {
                MenuMock menu = new MenuMock();
                menu.Name     = "menu" + i;
                menu.ParentId = i + 1;
                menu.insert();
            }


            List <MenuMock> list = cdb.findAll <MenuMock>();

            Assert.AreEqual(40, list.Count);

            Tree <MenuMock> _tree    = new Tree <MenuMock>(list);
            var             children = _tree.FindChildren(3);

            Assert.AreEqual(1, children.Count);
            Assert.AreEqual(23, children[0].getNode().Id);
        }
Esempio n. 3
0
        public void testMenuParentId()
        {
            List<MenuMock> oldList = cdb.findAll<MenuMock>();
            foreach (MenuMock menuMock in oldList) {
                menuMock.delete();
            }

            for (int i = 0; i < 20; i++) {
                MenuMock menu = new MenuMock();
                menu.Name = "menu" + i;
                menu.insert();
            }

            for (int i = 0; i < 20; i++) {
                MenuMock menu = new MenuMock();
                menu.Name = "menu" + i;
                menu.ParentId = i + 1;
                menu.insert();
            }

            List<MenuMock> list = cdb.findAll<MenuMock>();
            Assert.AreEqual( 40, list.Count );

            Tree<MenuMock> _tree = new Tree<MenuMock>( list );
            var children = _tree.FindChildren( 3 );
            Assert.AreEqual( 1, children.Count );
            Assert.AreEqual( 23, children[0].getNode().Id );
        }