public void AdminMenuItemsShortcutsHasToBeEnabledForNonAdminUsersIfAddedToNavigation() { #region Arrange var navigationItems = new List<MockNavigationItemInfo> { new MockNavigationItemInfo(1, "abc"), new MockNavigationItemInfo(2, "bcd"), new MockNavigationItemInfo(3, "cde"), }; var groupInfo = new MockNavigationGroupInfo(navigationItems, Constants.AdminMenu); var navigationItems1 = new List<MockNavigationItemInfo> { new MockNavigationItemInfo(2, "bcd"), }; var groupInfo1 = new MockNavigationGroupInfo(navigationItems1, "test"); var navItems = new MockNavigationGroupList(new[] { groupInfo, groupInfo1 }); var vm = new SysMenuViewModel(); vm.TheShell = Mock.Create<MainViewModel>(Behavior.Loose); vm.IsAdminEnabled = false; vm.MenuItemExtensions = new ExportFactory<ViewModelBase, IExportAsSystemMenuItemExtensionMetadata>[0]; vm.SetupAdminMenu(navItems); #endregion Arrange Assert.IsNull(vm.AdminMenuItems[0].Shortcut); Assert.IsNotNull(vm.AdminMenuItems[1].Shortcut); Assert.IsNull(vm.AdminMenuItems[2].Shortcut); }
public void AdminMenuItemsShortcutsHasToBeEnabledForAdminUsers() { #region Arrange var navigationItems = new List<MockNavigationItemInfo> { new MockNavigationItemInfo(1, "abc"), new MockNavigationItemInfo(2, "bcd"), new MockNavigationItemInfo(3, "cde"), }; var groupInfo = new MockNavigationGroupInfo(navigationItems, Constants.AdminMenu); var navItems = new MockNavigationGroupList(new[] { groupInfo }); var vm = new SysMenuViewModel(); vm.TheShell = Mock.Create<MainViewModel>(Behavior.Loose); vm.HandleEvent(new DashboardInitializationCompletedEvent()); vm.IsAdminEnabled = true; Mock.Arrange(() => Utils.CurrentUserAuthenticated).Returns(true); Mock.Arrange(() => Utils.CurrentUserHasAdministratorRights).Returns(true); vm.MenuItemExtensions = new ExportFactory<ViewModelBase, IExportAsSystemMenuItemExtensionMetadata>[0]; vm.SetupAdminMenu(navItems); #endregion Arrange Assert.IsNotNull(vm.AdminMenuItems[0].Shortcut); Assert.IsNotNull(vm.AdminMenuItems[1].Shortcut); Assert.IsNotNull(vm.AdminMenuItems[2].Shortcut); }