Пример #1
0
		public string GetMenu()
		{
			string html = "";

			if (_userContext.IsLoggedIn)
			{
				if (_userContext.IsAdmin)
				{
					html = _siteCache.GetAdminMenu();
				}
				else
				{
					html = _siteCache.GetLoggedInMenu();
				}
			}
			else
			{
				html = _siteCache.GetMenu();
			}

			// If the cache is empty, populate the right menu option
			if (string.IsNullOrEmpty(html))
			{
				SiteSettings siteSettings = _settingsRepository.GetSiteSettings();
				html = siteSettings.MenuMarkup;

				html = _markupConverter.ParseMenuMarkup(html);
				html = ReplaceKnownTokens(html);

				if (_userContext.IsLoggedIn)
				{
					if (_userContext.IsAdmin)
					{
						_siteCache.AddAdminMenu(html);
					}
					else
					{
						_siteCache.AddLoggedInMenu(html);
					}
				}
				else
				{
					_siteCache.AddMenu(html);
				}
			}

			return html;
		}
Пример #2
0
        public void getadminmenu_should_return_correct_html()
        {
            // Arrange
            string expectedHtml = "some html";

            CacheMock cache     = new CacheMock();
            SiteCache siteCache = new SiteCache(cache);

            siteCache.AddAdminMenu(expectedHtml);

            // Act
            string actualHtml = siteCache.GetAdminMenu();

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
Пример #3
0
        public void GetAdminMenu_Should_Return_Correct_Html()
        {
            // Arrange
            string expectedHtml = "some html";

            CacheMock           cache     = new CacheMock();
            ApplicationSettings settings  = new ApplicationSettings();
            SiteCache           siteCache = new SiteCache(settings, cache);

            siteCache.AddAdminMenu(expectedHtml);

            // Act
            string actualHtml = siteCache.GetAdminMenu();

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }