public void Throws_for_null_parameters() { using (var handler = new CommitFailureHandler()) { Assert.Equal( "connection", Assert.Throws <ArgumentNullException>(() => handler.MatchesParentContext(null, new DbInterceptionContext())) .ParamName); Assert.Equal( "interceptionContext", Assert.Throws <ArgumentNullException>(() => handler.MatchesParentContext(new Mock <DbConnection>().Object, null)) .ParamName); } }
public void Returns_false_with_ObjectContext_if_nothing_matches() { using (var handler = new CommitFailureHandler()) { handler.Initialize(MockHelper.CreateMockObjectContext <object>()); Assert.False( handler.MatchesParentContext( new Mock <DbConnection>().Object, new DbInterceptionContext().WithObjectContext(MockHelper.CreateMockObjectContext <object>()) .WithDbContext(new DbContext("c")))); } }
public void Returns_true_with_ObjectContext_if_no_context_same_connection() { var context = MockHelper.CreateMockObjectContext <object>(); using (var handler = new CommitFailureHandler()) { handler.Initialize(context); Assert.True( handler.MatchesParentContext( ((EntityConnection)context.Connection).StoreConnection, new DbInterceptionContext())); } }
public void Returns_true_with_DbContext_if_no_context_same_connection() { var connection = CreateMockConnection(); using (var handler = new CommitFailureHandler()) { handler.Initialize(new DbContext("c"), connection); Assert.True( handler.MatchesParentContext( connection, new DbInterceptionContext())); } }
public void Returns_true_with_ObjectContext_if_same_ObjectContext() { var context = MockHelper.CreateMockObjectContext <object>(); using (var handler = new CommitFailureHandler()) { handler.Initialize(context); Assert.True( handler.MatchesParentContext( new Mock <DbConnection>().Object, new DbInterceptionContext().WithObjectContext(context) .WithDbContext(new DbContext("c")))); } }
public void Returns_false_with_DbContext_if_different_context_same_connection() { var connection = CreateMockConnection(); using (var handler = new CommitFailureHandler()) { handler.Initialize(new DbContext("c"), connection); Assert.False( handler.MatchesParentContext( connection, new DbInterceptionContext().WithObjectContext(MockHelper.CreateMockObjectContext <object>()) .WithDbContext(new DbContext("c")))); } }
public void Returns_true_with_ObjectContext_if_no_context_same_connection() { var context = MockHelper.CreateMockObjectContext<object>(); using (var handler = new CommitFailureHandler()) { handler.Initialize(context); Assert.True( handler.MatchesParentContext( ((EntityConnection)context.Connection).StoreConnection, new DbInterceptionContext())); } }
public void Returns_true_with_ObjectContext_if_same_ObjectContext() { var context = MockHelper.CreateMockObjectContext<object>(); using (var handler = new CommitFailureHandler()) { handler.Initialize(context); Assert.True( handler.MatchesParentContext( new Mock<DbConnection>().Object, new DbInterceptionContext().WithObjectContext(context) .WithDbContext(new DbContext("c")))); } }
public void Returns_false_with_ObjectContext_if_nothing_matches() { using (var handler = new CommitFailureHandler()) { handler.Initialize(MockHelper.CreateMockObjectContext<object>()); Assert.False( handler.MatchesParentContext( new Mock<DbConnection>().Object, new DbInterceptionContext().WithObjectContext(MockHelper.CreateMockObjectContext<object>()) .WithDbContext(new DbContext("c")))); } }
public void Returns_false_with_DbContext_if_different_context_same_connection() { var connection = CreateMockConnection(); using (var handler = new CommitFailureHandler()) { handler.Initialize(new DbContext("c"), connection); Assert.False( handler.MatchesParentContext( connection, new DbInterceptionContext().WithObjectContext(MockHelper.CreateMockObjectContext<object>()) .WithDbContext(new DbContext("c")))); } }
public void Throws_for_null_parameters() { using (var handler = new CommitFailureHandler()) { Assert.Equal( "connection", Assert.Throws<ArgumentNullException>(() => handler.MatchesParentContext(null, new DbInterceptionContext())) .ParamName); Assert.Equal( "interceptionContext", Assert.Throws<ArgumentNullException>(() => handler.MatchesParentContext(new Mock<DbConnection>().Object, null)) .ParamName); } }