Exemple #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;
		}
Exemple #2
0
        public void getmenu_should_return_correct_html()
        {
            // Arrange
            string expectedHtml = "some html";

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

            siteCache.AddMenu(expectedHtml);

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

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
Exemple #3
0
        public void GetMenu_Should_Return_Correct_Html()
        {
            // Arrange
            string expectedHtml = "some html";

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

            siteCache.AddMenu(expectedHtml);

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

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