Пример #1
0
        public void CleanMainMenuModelInvalidTests()
        {
            //Arrange
            UserModel user = new UserModel
            {
                Email     = "*****@*****.**",
                SuperUser = true
            };

            //Act
            var cleanMenu = new MenuServices().CleanMainMenuModel(null, user);

            //Assert
            Assert.IsNull(cleanMenu);

            MainMenuModels menu = new MainMenuModels {
                MenuItems = null
            };

            cleanMenu = new MenuServices().CleanMainMenuModel(menu, user);

            //Assert
            Assert.IsNull(cleanMenu);

            menu      = MenuServicesTests.GetUnitTestMenu();
            cleanMenu = new MenuServices().CleanMainMenuModel(menu, null);

            //Assert
            Assert.IsNull(cleanMenu);
        }
Пример #2
0
        public void GetParentIdForMenuItemInvalidTests()
        {
            //Arrange
            var menu = MenuServicesTests.GetUnitTestMenu();

            //Act - fetch the parent ID
            MenuServices services = new MenuServices();
            int          parentId = services.GetParentIdForMenuItem("", menu);

            //Assert
            Assert.AreEqual(-1, parentId);

            parentId = services.GetParentIdForMenuItem(null, menu);

            //Assert
            Assert.AreEqual(-1, parentId);

            parentId = services.GetParentIdForMenuItem("Unit Test Testing", null);

            //Assert
            Assert.AreEqual(-1, parentId);

            menu = new MainMenuModels {
                MenuItems = null
            };

            parentId = services.GetParentIdForMenuItem("Unit Test Testing", menu);

            //Assert
            Assert.AreEqual(-1, parentId);
        }
Пример #3
0
        public void GetParentIdForMenuItemTests()
        {
            //Arrange
            var menu = MenuServicesTests.GetUnitTestMenu();

            //Act - fetch the parent ID
            MenuServices services = new MenuServices();
            int          parentId = services.GetParentIdForMenuItem("Unit Test Admin", menu);

            //Assert
            Assert.AreEqual(1, parentId);

            parentId = services.GetParentIdForMenuItem("Unit Test Development", menu);

            //Assert
            Assert.AreEqual(2, parentId);

            parentId = services.GetParentIdForMenuItem("Unit Test Testing", menu);

            //Assert
            Assert.AreEqual(3, parentId);

            parentId = services.GetParentIdForMenuItem("Unit Test Design", menu);

            //Assert
            Assert.AreEqual(4, parentId);
        }
Пример #4
0
        public void CleanMainMenuModelTests()
        {
            //Arrange
            var       menu = MenuServicesTests.GetUnitTestMenu();
            UserModel user = new UserModel
            {
                Email     = "*****@*****.**",
                SuperUser = true
            };

            //Act - remove all unit testing menu items from the menu
            var cleanMenu = new MenuServices().CleanMainMenuModel(menu, user);

            //Assert
            Assert.IsNotNull(cleanMenu);
            Assert.IsNotNull(cleanMenu.MenuItems);
            Assert.IsFalse(cleanMenu.MenuItems.Exists(m => m.DisplayText.ToLower().Contains("unit test")));
        }