public void Cache_Caches()
        {
            var cacheHelper = new CacheHelper(
                new ObjectCacheRuntimeCacheProvider(),
                new StaticCacheProvider(),
                new NullCacheProvider());

            var logger = new ProfilingLogger(Mock.Of <ILogger>(), Mock.Of <IProfiler>());
            var appCtx = new ApplicationContext(cacheHelper, logger);

            ApplicationContext.EnsureContext(appCtx, true);

            var prop1 = new MockPublishedContentProperty("myProperty1", "Test1");
            var prop2 = new MockPublishedContentProperty("myProperty2", "Test1");
            var prop3 = new MockPublishedContentProperty("myProperty3", "Test1");

            var content = new MockPublishedContent
            {
                Id         = 1,
                Properties = new[] { prop1, prop2, prop3 }
            };

            var model1 = content.As <MyValueResolverModel1>();
            var model2 = content.As <MyValueResolverModel2>();

            Assert.That(model1.MyProperty1, Is.EqualTo("Test1"));
            Assert.That(model1.MyProperty2, Is.EqualTo("Test1"));
            Assert.That(model1.MyProperty3, Is.EqualTo("Test1"));

            Assert.That(model2.MyProperty1, Is.EqualTo("Test1"));
            Assert.That(model2.MyProperty2, Is.EqualTo("Test1"));
            Assert.That(model2.MyProperty3, Is.EqualTo("Test1"));

            prop1.Value = "Test2";
            prop2.Value = "Test2";
            prop3.Value = "Test2";

            model1 = content.As <MyValueResolverModel1>();
            model2 = content.As <MyValueResolverModel2>();

            Assert.That(model1.MyProperty1, Is.EqualTo("Test1"));
            Assert.That(model1.MyProperty2, Is.EqualTo("Test1"));
            Assert.That(model1.MyProperty3, Is.EqualTo("Test2")); // This one doesn't cache

            Assert.That(model2.MyProperty1, Is.EqualTo("Test1"));
            Assert.That(model2.MyProperty2, Is.EqualTo("Test1"));
            Assert.That(model2.MyProperty3, Is.EqualTo("Test1"));
        }
        public void Json_Serialize_Object_Mapping()
        {
            var txt = "foo bar";
            var obj = new MyJsonModel {
                Name = txt
            };

            var value = JObject.FromObject(obj);

            Assert.That(value, Is.Not.Null);

            var property = new MockPublishedContentProperty("myProperty", value);
            var content  = new MockPublishedContent {
                Properties = new[] { property }
            };

            var model = content.As <MyModel>();

            Assert.That(model, Is.Not.Null);
            Assert.That(model.MyProperty, Is.TypeOf <MyJsonModel>());
            Assert.That(model.MyProperty, Is.Not.Null);
            Assert.That(model.MyProperty.Name, Is.EqualTo(txt));
        }