public void PrefetchLoadsCache()
        {
            CacheSettingsProvider doc = new CacheSettingsProvider(this);

            object returned = doc.GetValue("1234", "5678"); //See the Prefetch thing

            Assert.AreEqual(42, returned);
            Assert.AreEqual(0, getValueHits);
        }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         RefererValidationProvider.CheckMainPageReferer();
         Page MainForm = this;
         Ajax.Utility.GenerateMethodScripts(MainForm);
         this.SetCurrentUser();
         CacheSettingsProvider.ClearCache();
         this.CreateAccessNotAllowdNavBarItemsList();
         this.GetCurrentLangID();
         this.InitializeSkin();
         ScriptHelper.InitializeScripts(this.Page, typeof(Scripts));
     }
 }
        public void SetValueUpdatesTheCache()
        {
            CacheSettingsProvider doc = new CacheSettingsProvider(this);
            string testSection        = "foo";
            string testEntry          = "bar";

            getValueReturns = 42;

            Assert.AreEqual(42, doc.GetValue(testSection, testEntry));
            doc.SetValue(testSection, testEntry, 666);
            Assert.AreEqual(666, doc.GetValue(testSection, testEntry));

            Assert.AreEqual(1, getValueHits);
            Assert.AreEqual(1, setValueHits);
        }
        public void RemoveValueRemovesFromCache()
        {
            CacheSettingsProvider doc = new CacheSettingsProvider(this);
            string testSection        = "foo";
            string testEntry          = "bar";

            getValueReturns = 42;

            doc.GetValue(testSection, testEntry);
            doc.RemoveEntry(testSection, testEntry);
            doc.GetValue(testSection, testEntry);

            Assert.AreEqual(2, getValueHits);
            Assert.AreEqual(1, removeEntryHits);
        }
        public void GetValueTwiceUsesCache()
        {
            CacheSettingsProvider doc = new CacheSettingsProvider(this);
            string testSection        = "foo";
            string testEntry          = "bar";

            getValueReturns = 42;

            object returned = doc.GetValue(testSection, testEntry);

            Assert.AreEqual(this.getValueReturns, returned);

            doc.GetValue(testSection, testEntry);
            doc.GetValue(testSection, testEntry);
            Assert.AreEqual(1, getValueHits);
        }
        public void GetValueAsksInnerXmlDoc()
        {
            CacheSettingsProvider doc = new CacheSettingsProvider(this);
            string testSection        = "foo";
            string testEntry          = "bar";

            getValueReturns = 42;

            object returned = doc.GetValue(testSection, testEntry);

            Assert.AreEqual(this.getValueReturns, returned);

            Assert.AreEqual(testSection, section);
            Assert.AreEqual(testEntry, entry);
            Assert.AreEqual(1, getValueHits);
        }