Пример #1
0
        public void AccessTimeoutTest()
        {
            NFileCache target = new NFileCache("AccessTimeoutTest");
            target.AccessTimeout = new TimeSpan(1);
            target["foo"] = 0;

            // Lock actual file system record
            string itemPath = target.GetItemPath("foo");
            using (FileStream stream = File.Open(itemPath, FileMode.Create))
            {
                object result = target["foo"];
            }
        }
Пример #2
0
        public void AccessTimeoutTest()
        {
            NFileCache target = new NFileCache("AccessTimeoutTest");

            target.AccessTimeout = new TimeSpan(1);
            target["foo"]        = 0;

            // Lock actual file system record
            string itemPath = target.GetItemPath("foo");

            using (FileStream stream = File.Open(itemPath, FileMode.Create))
            {
                object result = target["foo"];
            }
        }
Пример #3
0
        public void RemoveTest()
        {
            NFileCache target = new NFileCache("RemoveTest");

            target.Set("test", "test", DateTime.Now.AddDays(3));
            object result = target.Get("test");

            Assert.AreEqual("test", result);

            // Check file system to be sure item was created
            string itemPath = target.GetItemPath("test");

            Assert.IsTrue(File.Exists(itemPath));

            // Now delete
            target.Remove("test");
            result = target["test"];
            Assert.IsNull(result);

            // Check file system to be sure item was removed
            Assert.IsFalse(File.Exists(itemPath));
        }
Пример #4
0
        public void RemoveTest()
        {
            NFileCache target = new NFileCache("RemoveTest");
            target.Set("test", "test", DateTime.Now.AddDays(3));
            object result = target.Get("test");
            Assert.AreEqual("test", result);

            // Check file system to be sure item was created
            string itemPath = target.GetItemPath("test");
            Assert.IsTrue(File.Exists(itemPath));

            // Now delete
            target.Remove("test");
            result = target["test"];
            Assert.IsNull(result);

            // Check file system to be sure item was removed
            Assert.IsFalse(File.Exists(itemPath));
        }