public void SiteMapForAdministrators()
        {
            string siteMapFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../TestData/siteMap.config");
            IRoleApi roleApi = this.mockRepository.StrictMock<IRoleApi>();
            Expect.Call(roleApi.IsUserInRole(Guid.Empty, Guid.Empty)).IgnoreArguments().Return(true);
            SiteMapApi siteMapApi = new SiteMapApi(authenticationContext, roleApi, organizationApi, null, platformConfiguration, siteMapFilePath);

            this.mockRepository.ReplayAll();

            IEnumerable<SiteMapItemConfig> siteMapItems = siteMapApi.FindSiteMapConfig(authenticationContext.User.UserId);
            Assert.AreEqual(2, siteMapItems.Count());

            SiteMapItemConfig accountSiteMapItem = siteMapItems.First();
            string accountText = GlobalizationUtility.ReplaceGlobalizationVariables("$Resources.SiteMap.Account, RapidWebDev.Web$");
            Assert.AreEqual(accountText, accountSiteMapItem.Text);
        }
        public void SiteMapForNonAdministratorsWithAllPermissions()
        {
            string siteMapFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../TestData/siteMap.config");
            IRoleApi roleApi = this.mockRepository.StrictMock<IRoleApi>();
            Expect.Call(roleApi.IsUserInRole(Guid.Empty, Guid.Empty)).IgnoreArguments().Return(false);

            IPermissionApi permissionApi = this.mockRepository.StrictMock<IPermissionApi>();

            // there are 12 sitemap elements which have the attribute "Value".
            Expect.Call(permissionApi.HasPermission(Guid.Empty, null))
                .IgnoreArguments()
                .Return(true)
                .Repeat.Times(12);

            SiteMapApi siteMapApi = new SiteMapApi(authenticationContext, roleApi, organizationApi, permissionApi, platformConfiguration, siteMapFilePath);
            this.mockRepository.ReplayAll();

            IEnumerable<SiteMapItemConfig> siteMapItems = siteMapApi.FindSiteMapConfig(authenticationContext.User.UserId);
            Assert.AreEqual(2, siteMapItems.Count());
        }
        public void SiteMapForNonAdministratorsWithPartialPermissions()
        {
            string siteMapFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../TestData/siteMap.config");
            IRoleApi roleApi = this.mockRepository.StrictMock<IRoleApi>();
            Expect.Call(roleApi.IsUserInRole(Guid.Empty, Guid.Empty)).IgnoreArguments().Return(false);

            IPermissionApi permissionApi = this.mockRepository.StrictMock<IPermissionApi>();

            Guid userId = authenticationContext.User.UserId;
            // there are 4 sitemap elements which have the attribute "Value" equals to "EveryOne".
            Expect.Call(permissionApi.HasPermission(userId, "EveryOne"))
                .Return(true)
                .Repeat.Times(4);

            // there are 8 sitemap elements which have the attribute "Value" not equals to "EveryOne".
            Expect.Call(permissionApi.HasPermission(userId, "OrganizationTypeManagement")).Return(false);
            Expect.Call(permissionApi.HasPermission(userId, "DepartmentManagement")).Return(false);
            Expect.Call(permissionApi.HasPermission(userId, "CustomerManagement")).Return(false);
            Expect.Call(permissionApi.HasPermission(userId, "Department.RoleManagement")).Return(false);
            Expect.Call(permissionApi.HasPermission(userId, "Customer.RoleManagement")).Return(false);
            Expect.Call(permissionApi.HasPermission(userId, "Department.UserManagement")).Return(false);
            Expect.Call(permissionApi.HasPermission(userId, "Customer.UserManagement")).Return(false);
            Expect.Call(permissionApi.HasPermission(userId, "AreaManagement")).Return(false);

            SiteMapApi siteMapApi = new SiteMapApi(authenticationContext, roleApi, organizationApi, permissionApi, platformConfiguration, siteMapFilePath);
            this.mockRepository.ReplayAll();

            IEnumerable<SiteMapItemConfig> siteMapItems = siteMapApi.FindSiteMapConfig(userId);
            Assert.AreEqual(1, siteMapItems.Count());
        }