Example #1
0
        public void TestGetOrSetIfNew()
        {
            var expTestObject = new TestObject { Prop1 = "test", Prop2 = 1234 };
            var actTestObject = ObjectCache.Instance.GetOrSetObject("testObj", () => new TestObject { Prop1 = "test", Prop2 = 1234 });

            Assert.AreEqual(expTestObject.Prop1, actTestObject.Prop1);
            Assert.AreEqual(expTestObject.Prop2, actTestObject.Prop2);

            FileAssert.Exists(actualPath);
            FileAssert.AreEqual(expectedPath, actualPath);
        }
Example #2
0
        public void TestGetOrSetIfExists()
        {
            string path = Path.Combine(Environment.CurrentDirectory, "cache");
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            File.Copy(this.expectedPath, this.actualPath, true);

            var expTestObject = new TestObject { Prop1 = "test", Prop2 = 1234 };
            var actTestObject = ObjectCache.Instance.GetOrSetObject("testObj", () => new TestObject { Prop1 = "test", Prop2 = 1234 });

            Assert.AreEqual(expTestObject.Prop1, actTestObject.Prop1);
            Assert.AreEqual(expTestObject.Prop2, actTestObject.Prop2);

            FileAssert.Exists(actualPath);
            FileAssert.AreEqual(expectedPath, actualPath);
        }
Example #3
0
        public void TestStoring()
        {
            var testObject = new TestObject { Prop1 = "test", Prop2 = 1234 };
            ObjectCache.Instance.SetObject("testObj", testObject);

            FileAssert.Exists(actualPath);
            FileAssert.AreEqual(expectedPath, actualPath);
        }