public void tracks_updates_to_object_graph_child_in_context()
        {
            //setup
            var context = CreateUserContext();
            var mockPublisher = new Mock<IAuditEventPublisher>();
            var id = AddCountryAndReturnId();
            int stateId;

            //act
            using (var subject = new TestAuditableContext(GetEFConnectionString(), context, mockPublisher.Object, _defaultMockConfiguration.Object))
            {
                subject.ContextOptions.LazyLoadingEnabled = true;
                subject.ContextOptions.ProxyCreationEnabled = true;

                var objectSet = subject.CreateObjectSet<Country>();
                var country = objectSet.Single(c => c.Id == id);
                var state = country.States.ElementAt(0);
                stateId = state.Id;
                state.Name = Guid.NewGuid().ToString();
                subject.SaveChanges();
            }

            //assert
            mockPublisher.Verify
                (
                m => m.Publish
                    (
                        It.Is<AuditEvent>
                        (
                            auditEvent =>
                            EventMatchesContext(auditEvent, context)
                            &&
                            auditEvent.AuditEntities.Count() == 1
                            &&
                            auditEvent.AuditEntities[0].EntityType == typeof(State).Name
                            &&
                            auditEvent.AuditEntities[0].EntityIdentifier == stateId.ToString()
                            &&
                            auditEvent.AuditEntities[0].AuditEntityAction == AuditEntityAction.Update
                        )
                    ),
                    Times.Once()
                );
        }
        public void tracks_updates_in_context()
        {
            //setup
            var context = CreateUserContext();
            var mockPublisher = new Mock<IAuditEventPublisher>();
            var id = AddGenderAndReturnId();

            //act
            using (var subject = new TestAuditableContext(GetEFConnectionString(), context, mockPublisher.Object, _defaultMockConfiguration.Object))
            {
                var objectSet = subject.CreateObjectSet<Gender>();
                var currentEntity = objectSet.Single(g => g.Id == id);
                currentEntity.Name = Guid.NewGuid().ToString();
                subject.SaveChanges();
            }

            //assert
            mockPublisher.Verify
                (
                m => m.Publish
                    (
                        It.Is<AuditEvent>
                        (
                            auditEvent =>
                            EventMatchesContext(auditEvent, context)
                            &&
                            auditEvent.AuditEntities.Count() == 1
                            &&
                            auditEvent.AuditEntities[0].AuditEntityAction == AuditEntityAction.Update
                        )
                    ),
                    Times.Once()
                );
        }