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); }
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()); }
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()); }
/// <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; }