public void GetMappingItemCollection_throws_for_null_viewCacheFactory() { Assert.Equal( "viewCacheFactory", Assert.Throws <ArgumentNullException>( () => InteractiveViews.GetMappingItemCollection(null)).ParamName); }
public void GetMappingItemCollection_throws_if_no_mapping_item_collection_for_viewCacheFactory() { Assert.Equal( "No StorageMappingItemCollection instance found for the provided DbMappingViewCacheFactory.", Assert.Throws <InvalidOperationException>( () => InteractiveViews.GetMappingItemCollection(new Mock <DbMappingViewCacheFactory>().Object)) .Message); }
public void SetViewCacheFactory_registers_factory_for_DbContext() { using (var ctx = new DbContext(TestUtils.TempDbConnectionString)) { var viewCacheFactory = new Mock <DbMappingViewCacheFactory>().Object; InteractiveViews.SetViewCacheFactory(ctx, viewCacheFactory); var mappingItemCollection = (StorageMappingItemCollection) (((IObjectContextAdapter)ctx).ObjectContext) .MetadataWorkspace.GetItemCollection(DataSpace.CSSpace); Assert.Same(mappingItemCollection, InteractiveViews.GetMappingItemCollection(viewCacheFactory)); Assert.Same(viewCacheFactory, mappingItemCollection.MappingViewCacheFactory); } }
public void SetViewCacheFactory_registers_factory_for_ObjectContext() { using (var entityConnection = new EntityConnection(TestUtils.CreateFakeMetadataWorkspace(), new SqlConnection(TestUtils.TempDbConnectionString))) { using (var objectCtx = new ObjectContext(entityConnection)) { var viewCacheFactory = new Mock <DbMappingViewCacheFactory>().Object; InteractiveViews.SetViewCacheFactory(objectCtx, viewCacheFactory); var mappingItemCollection = (StorageMappingItemCollection)objectCtx .MetadataWorkspace.GetItemCollection(DataSpace.CSSpace); Assert.Same(mappingItemCollection, InteractiveViews.GetMappingItemCollection(viewCacheFactory)); Assert.Same(viewCacheFactory, mappingItemCollection.MappingViewCacheFactory); } } }
// virtual for mocking internal virtual StorageMappingItemCollection GetMappingItemCollection() { return(InteractiveViews.GetMappingItemCollection(this)); }