internal DbCommandDefinition CreateCommandDefinition(DbCommandTree commandTree, DbInterceptionContext interceptionContext) { DebugCheck.NotNull(commandTree); DebugCheck.NotNull(interceptionContext); ValidateDataSpace(commandTree); var storeMetadata = (StoreItemCollection)commandTree.MetadataWorkspace.GetItemCollection(DataSpace.SSpace); Debug.Assert( storeMetadata.StoreProviderManifest != null, "StoreItemCollection has null StoreProviderManifest?"); commandTree = _treeDispatcher.Created(commandTree, interceptionContext); return(CreateDbCommandDefinition(storeMetadata.StoreProviderManifest, commandTree)); }
public void Created_dispatches_to_interceptors_which_can_modify_result() { var interceptionContext = new DbInterceptionContext(); var tree = new Mock<DbCommandTree>().Object; var mockInterceptor = new Mock<IDbCommandTreeInterceptor>(); var interceptedTree = new Mock<DbCommandTree>().Object; mockInterceptor.Setup(m => m.TreeCreated(tree, interceptionContext)).Returns(interceptedTree); var dispatcher = new DbCommandTreeDispatcher(); var internalDispatcher = dispatcher.InternalDispatcher; internalDispatcher.Add(mockInterceptor.Object); Assert.Same(interceptedTree, dispatcher.Created(tree, interceptionContext)); mockInterceptor.Verify(m => m.TreeCreated(tree, interceptionContext)); }