public void Can_create_instance_with_valid_context_and_cache_types()
        {
            var attribute = new DbMappingViewCacheTypeAttribute(typeof(SampleContext), typeof(SampleMappingViewCache));

            Assert.Same(typeof(SampleContext), attribute.ContextType);
            Assert.Same(typeof(SampleMappingViewCache), attribute.CacheType);
        }
        public void Can_create_instance_with_valid_context_type_and_cache_type_name()
        {
            var cacheTypeName = typeof(SampleMappingViewCache).AssemblyQualifiedName;
            var attribute     = new DbMappingViewCacheTypeAttribute(typeof(SampleContext), cacheTypeName);

            Assert.Same(typeof(SampleContext), attribute.ContextType);
            Assert.Same(typeof(SampleMappingViewCache), attribute.CacheType);
        }
コード例 #3
0
        public void Different_instances_with_same_attribute_are_equal()
        {
            var attribute = new DbMappingViewCacheTypeAttribute(typeof(SampleContext), typeof(SampleMappingViewCache));
            var factory1 = new DefaultDbMappingViewCacheFactory(attribute);
            var factory2 = new DefaultDbMappingViewCacheFactory(attribute);

            Assert.True(factory1.Equals(factory2));
            Assert.True(factory2.Equals(factory1));
            Assert.True(factory1.GetHashCode() == factory2.GetHashCode());
        }
コード例 #4
0
        public void Create_returns_instance_of_type_specified_by_attribute()
        {
            var attribute = new DbMappingViewCacheTypeAttribute(typeof(SampleContext), typeof(SampleMappingViewCache));
            var factory = new DefaultDbMappingViewCacheFactory(attribute);

            var cache = factory.Create("C", "S");

            Assert.NotNull(cache);
            Assert.Same(typeof(SampleMappingViewCache), cache.GetType());
        }
コード例 #5
0
        public void Different_instances_with_same_attribute_are_equal()
        {
            var attribute = new DbMappingViewCacheTypeAttribute(typeof(SampleContext), typeof(SampleMappingViewCache));
            var factory1  = new DefaultDbMappingViewCacheFactory(attribute);
            var factory2  = new DefaultDbMappingViewCacheFactory(attribute);

            Assert.True(factory1.Equals(factory2));
            Assert.True(factory2.Equals(factory1));
            Assert.True(factory1.GetHashCode() == factory2.GetHashCode());
        }
コード例 #6
0
        public void Create_returns_instance_of_type_specified_by_attribute()
        {
            var attribute = new DbMappingViewCacheTypeAttribute(typeof(SampleContext), typeof(SampleMappingViewCache));
            var factory   = new DefaultDbMappingViewCacheFactory(attribute);

            var cache = factory.Create("C", "S");

            Assert.NotNull(cache);
            Assert.Same(typeof(SampleMappingViewCache), cache.GetType());
        }
コード例 #7
0
        /// <summary>
        /// Creates a new DefaultDbMappingViewCacheFactory instance.
        /// </summary>
        /// <param name="attribute">A DbMappingViewCacheTypeAttribute 
        /// that specifies the cache type.</param>
        public DefaultDbMappingViewCacheFactory(DbMappingViewCacheTypeAttribute attribute)
        {
            DebugCheck.NotNull(attribute);

            _attribute = attribute;
        }
コード例 #8
0
        /// <summary>
        /// Creates a new DefaultDbMappingViewCacheFactory instance.
        /// </summary>
        /// <param name="attribute">A DbMappingViewCacheTypeAttribute
        /// that specifies the cache type.</param>
        public DefaultDbMappingViewCacheFactory(DbMappingViewCacheTypeAttribute attribute)
        {
            DebugCheck.NotNull(attribute);

            _attribute = attribute;
        }