public virtual DbCommandTree Created(DbCommandTree commandTree, DbInterceptionContext interceptionContext) { DebugCheck.NotNull(commandTree); DebugCheck.NotNull(interceptionContext); var clonedInterceptionContext = new DbCommandTreeInterceptionContext(interceptionContext); return(InternalDispatcher.Dispatch( commandTree, clonedInterceptionContext, i => i.TreeCreated(commandTree, clonedInterceptionContext))); }
public void Cloning_the_interception_context_preserves_contextual_information_but_not_mutable_state() { var objectContext = new ObjectContext(); var dbContext = CreateDbContext(objectContext); var interceptionContext = new DbCommandTreeInterceptionContext(); interceptionContext.MutableData.SetExecuted(new Mock <DbCommandTree>().Object); interceptionContext = interceptionContext .WithDbContext(dbContext) .WithObjectContext(objectContext) .AsAsync(); Assert.Equal(new[] { objectContext }, interceptionContext.ObjectContexts); Assert.Equal(new[] { dbContext }, interceptionContext.DbContexts); Assert.True(interceptionContext.IsAsync); Assert.Null(interceptionContext.Result); Assert.Null(interceptionContext.OriginalResult); }
public void Result_can_be_mutated() { var interceptionContext = new DbCommandTreeInterceptionContext(); Assert.Null(interceptionContext.Result); Assert.Null(interceptionContext.OriginalResult); var commandTree = new Mock <DbCommandTree>().Object; interceptionContext.MutableData.SetExecuted(commandTree); Assert.Same(commandTree, interceptionContext.Result); Assert.Same(commandTree, interceptionContext.OriginalResult); var commandTree2 = new Mock <DbCommandTree>().Object; interceptionContext.Result = commandTree2; Assert.Same(commandTree2, interceptionContext.Result); Assert.Same(commandTree, interceptionContext.OriginalResult); }
public abstract void TreeCreated(DbCommandTree commandTree, DbCommandTreeInterceptionContext interceptionContext);