Beispiel #1
0
		public void addloggedinmenu_should_cache_html()
		{
			// Arrange
			CacheMock cache = new CacheMock();
			SiteCache siteCache = new SiteCache(cache);

			// Act
			siteCache.AddLoggedInMenu("some html");

			// Assert
			Assert.That(cache.Count(), Is.EqualTo(1));
			IEnumerable<string> keys = cache.Select(x => x.Key);
			Assert.That(keys, Contains.Item(CacheKeys.LoggedInMenuKey()));
		}
Beispiel #2
0
        public void AddMenu_Should_Cache_Html()
        {
            // Arrange
            CacheMock cache = new CacheMock();
            ApplicationSettings settings = new ApplicationSettings();
            SiteCache siteCache = new SiteCache(settings, cache);

            // Act
            siteCache.AddMenu("some html");

            // Assert
            Assert.That(cache.Count(), Is.EqualTo(1));
            IEnumerable<string> keys = cache.Select(x => x.Key);
            Assert.That(keys, Contains.Item(CacheKeys.MenuKey()));
        }
		public void removeall_should_remove_pageviewmodelcache_keys_only()
		{
			// Arrange
			CacheMock cache = new CacheMock();
			cache.Add("site.blah", "xyz", new CacheItemPolicy());

			ApplicationSettings settings = new ApplicationSettings() { UseObjectCache = false };
			PageViewModelCache pageCache = new PageViewModelCache(settings, cache);
			pageCache.Add(1, 1, new PageViewModel());

			// Act
			pageCache.RemoveAll();

			// Assert
			Assert.That(cache.Count(), Is.EqualTo(1));
		}
Beispiel #4
0
        public void RemoveAll_Should_Remove_ListCache_Keys_Only()
        {
            // Arrange
            CacheMock cache = new CacheMock();
            cache.Add("site.blah", "xyz", new CacheItemPolicy());

            ApplicationSettings settings = new ApplicationSettings() { UseObjectCache = true };

            List<string> tagCacheItems1 = new List<string>() { "1", "2" };
            List<string> tagCacheItems2 = new List<string>() { "1", "2" };
            AddToCache(cache, "all.tags1", tagCacheItems1);
            AddToCache(cache, "all.tags2", tagCacheItems2);

            ListCache listCache = new ListCache(settings, cache);

            // Act
            listCache.RemoveAll();

            // Assert
            Assert.That(cache.Count(), Is.EqualTo(1));
        }
Beispiel #5
0
        public void UpdatePluginSettings_Should_Add_Plugin_Settings_ToCache()
        {
            // Arrange
            CacheMock cache = new CacheMock();
            ApplicationSettings settings = new ApplicationSettings();
            SiteCache siteCache = new SiteCache(settings, cache);

            TextPluginStub plugin = new TextPluginStub();
            plugin.PluginCache = siteCache;
            plugin.Repository = new RepositoryMock();
            plugin.Settings.SetValue("foo", "bar");

            // Act
            siteCache.UpdatePluginSettings(plugin);

            // Assert
            Assert.That(cache.Count(), Is.EqualTo(1));
        }
Beispiel #6
0
        public void RemoveMenuCacheItems_Should_Clear_Cache_Items()
        {
            // Arrange
            CacheMock cache = new CacheMock();
            ApplicationSettings settings = new ApplicationSettings() { UseObjectCache = true };

            SiteCache siteCache = new SiteCache(settings, cache);
            siteCache.AddMenu("menu html");
            siteCache.AddLoggedInMenu("logged in menu html");
            siteCache.AddAdminMenu("admin menu html");

            // Act
            siteCache.RemoveMenuCacheItems();

            // Assert
            Assert.That(cache.Count(), Is.EqualTo(0));
        }
Beispiel #7
0
        public void RemoveAll_Should_Remove_SiteCache_Keys_Only()
        {
            // Arrange
            CacheMock cache = new CacheMock();
            cache.Add("list.blah", "xyz", new CacheItemPolicy());
            ApplicationSettings settings = new ApplicationSettings();
            SiteCache siteCache = new SiteCache(settings, cache);

            siteCache.AddMenu("menu html");
            siteCache.AddLoggedInMenu("logged in menu html");
            siteCache.AddAdminMenu("admin menu html");

            TextPluginStub plugin = new TextPluginStub();
            plugin.PluginCache = siteCache;
            plugin.Repository = new RepositoryMock();
            plugin.Settings.SetValue("foo", "bar");

            // Act
            siteCache.RemoveAll();

            // Assert
            Assert.That(cache.Count(), Is.EqualTo(1));
        }
Beispiel #8
0
		public void removepluginsettings_should_remove_plugin_settings()
		{
			// Arrange
			CacheMock cache = new CacheMock();
			SiteCache siteCache = new SiteCache(cache);

			TextPluginStub plugin = new TextPluginStub();
			plugin.PluginCache = siteCache;
			plugin.Repository = new SettingsRepositoryMock();
			plugin.Settings.SetValue("foo", "bar");

			// Act
			siteCache.RemovePluginSettings(plugin);

			// Assert
			Assert.That(cache.Count(), Is.EqualTo(0));
		}
Beispiel #9
0
		public void removemenucacheitems_should_clear_cache_items()
		{
			// Arrange
			CacheMock cache = new CacheMock();

			SiteCache siteCache = new SiteCache(cache);
			siteCache.AddMenu("menu html");
			siteCache.AddLoggedInMenu("logged in menu html");
			siteCache.AddAdminMenu("admin menu html");

			// Act
			siteCache.RemoveMenuCacheItems();

			// Assert
			Assert.That(cache.Count(), Is.EqualTo(0));
		}