public void ContextKey_returns_to_string_of_context_type() { var genericFuncy = new GT<NT, NT>.GenericFuncy<GT<GT<NT, NT>, NT>, NT>(); var internalContext = new EagerInternalContext(genericFuncy); Assert.Equal(genericFuncy.GetType().ToString(), internalContext.ContextKey); }
public void ContextKey_returns_to_string_of_context_type() { var genericFuncy = new GT <NT, NT> .GenericFuncy <GT <GT <NT, NT>, NT>, NT>(); var internalContext = new EagerInternalContext(genericFuncy); Assert.Equal(genericFuncy.GetType().ToString(), internalContext.ContextKey); }
public void OptimisticConcurrencyException_with_null_entries_is_wrapped_as_normal_update_exception() { var original = new OptimisticConcurrencyException("Bang!"); var wrapped = new EagerInternalContext(new Mock <DbContext>().Object).WrapUpdateException(original); Assert.IsType <DbUpdateConcurrencyException>(wrapped); Assert.Equal("Bang!", wrapped.Message); Assert.Empty(wrapped.Entries); Assert.Same(original, wrapped.InnerException); }
public void OptimisticConcurrencyException_with_relationship_entries_is_wrapped_as_IA_update_exception() { var original = new OptimisticConcurrencyException("Bang!", null, new[] { CreateEntityEntry(), CreateRelationshipEntry() }); var wrapped = new EagerInternalContext(new Mock <DbContext>().Object).WrapUpdateException(original); Assert.IsType <DbUpdateException>(wrapped); Assert.Equal(Strings.DbContext_IndependentAssociationUpdateException, wrapped.Message); Assert.Empty(wrapped.Entries); Assert.Same(original, wrapped.InnerException); }
public void OnDisposing_event_is_raised_when_once_when_context_is_disposed_and_never_again() { var eventCount = 0; var context = new EagerInternalContext(new Mock<DbContext>().Object); context.OnDisposing += (_, __) => eventCount++; context.Dispose(); Assert.Equal(1, eventCount); context.Dispose(); Assert.Equal(1, eventCount); }
public void OnDisposing_event_is_raised_when_once_when_context_is_disposed_and_never_again() { var eventCount = 0; var context = new EagerInternalContext(new Mock <DbContext>().Object); context.OnDisposing += (_, __) => eventCount++; context.Dispose(); Assert.Equal(1, eventCount); context.Dispose(); Assert.Equal(1, eventCount); }
public void UpdateException_without_relationship_entries_is_wrapped_as_normal_update_exception() { var entity1 = new object(); var entity2 = new object(); var original = new UpdateException("Bang!", null, new[] { CreateEntityEntry(entity1), CreateEntityEntry(entity2) }); var wrapped = new EagerInternalContext(new Mock <DbContext>().Object).WrapUpdateException(original); Assert.IsType <DbUpdateException>(wrapped); Assert.Equal("Bang!", wrapped.Message); Assert.Equal(2, wrapped.Entries.Count()); Assert.Same(entity1, wrapped.Entries.First().Entity); Assert.Same(entity2, wrapped.Entries.Skip(1).First().Entity); Assert.Same(original, wrapped.InnerException); }
public void CommandTimeout_is_obtained_from_and_set_in_ObjectContext_if_ObjectContext_exists() { using (var context = new DummyContext()) { var objectContext = ((IObjectContextAdapter)context).ObjectContext; objectContext.CommandTimeout = 77; var internalContext = new EagerInternalContext(context, objectContext, false); Assert.Equal(77, internalContext.CommandTimeout); internalContext.CommandTimeout = 88; Assert.Equal(88, objectContext.CommandTimeout); } }