public void EditEntityTest() { using (var session = Domain.OpenSession()) using (var eventInfo = new EventInfo(session)) { using (var transactionScope = session.OpenTransaction()) { var entity = new MegaEntity(); Assert.IsNotNull(eventInfo.EntityCreatedArgs); Assert.AreEqual(entity, eventInfo.EntityCreatedArgs.Entity); eventInfo.ResetEventArgs(); entity.Value = 2; Assert.IsNotNull(eventInfo.EntityFieldValueSettingArgs); Assert.AreEqual(entity, eventInfo.EntityFieldValueSettingArgs.Entity); Assert.AreEqual(2, eventInfo.EntityFieldValueSettingArgs.Value); Assert.IsNotNull(eventInfo.EntityFieldValueSetArgs); Assert.AreEqual(entity, eventInfo.EntityFieldValueSetArgs.Entity); Assert.AreEqual(0, eventInfo.EntityFieldValueSetArgs.OldValue); Assert.AreEqual(2, eventInfo.EntityFieldValueSetArgs.NewValue); eventInfo.ResetEventArgs(); int value = entity.Value; Assert.IsNull(eventInfo.EntityFieldValueSettingArgs); Assert.IsNull(eventInfo.EntityFieldValueSetArgs); Assert.IsNotNull(eventInfo.EntityFieldGettingArgs); Assert.AreEqual(entity, eventInfo.EntityFieldGettingArgs.Entity); Assert.IsNotNull(eventInfo.EntityFieldValueGetArgs); Assert.AreEqual(entity, eventInfo.EntityFieldValueGetArgs.Entity); Assert.AreEqual(2, eventInfo.EntityFieldValueGetArgs.Value); eventInfo.ResetEventArgs(); entity.Remove(); Assert.IsNotNull(eventInfo.EntityRemoving); Assert.AreEqual(entity, eventInfo.EntityRemoving.Entity); Assert.IsNotNull(eventInfo.EntityRemoved); Assert.AreEqual(entity, eventInfo.EntityRemoved.Entity); } } }
private void EditEntity() { using (var transactionScope = Session.Demand().OpenTransaction()) { ClearEvents(); var entity = new MegaEntity(); Assert.IsNotNull(entityCreatedArgs); Assert.AreEqual(entity, entityCreatedArgs.Entity); ClearEvents(); entity.Value = 2; Assert.IsNotNull(entityEntityFieldSettingArgs); Assert.AreEqual(entity, entityEntityFieldSettingArgs.Entity); Assert.AreEqual(2, entityEntityFieldSettingArgs.Value); Assert.IsNotNull(entityEntityFieldSetArgs); Assert.AreEqual(entity, entityEntityFieldSetArgs.Entity); Assert.AreEqual(0, entityEntityFieldSetArgs.OldValue); Assert.AreEqual(2, entityEntityFieldSetArgs.NewValue); ClearEvents(); int value = entity.Value; Assert.IsNull(entityEntityFieldSettingArgs); Assert.IsNull(entityEntityFieldSetArgs); Assert.IsNotNull(entityEntityFieldGettingArgs); Assert.AreEqual(entity, entityEntityFieldGettingArgs.Entity); Assert.IsNotNull(entityEntityFieldArgs); Assert.AreEqual(entity, entityEntityFieldArgs.Entity); Assert.AreEqual(2, entityEntityFieldArgs.Value); ClearEvents(); entity.Remove(); Assert.IsNotNull(entityRemoving); Assert.AreEqual(entity, entityRemoving.Entity); Assert.IsNotNull(entityRemoved); Assert.AreEqual(entity, entityRemoved.Entity); } }