public void OneToManyRemovalTest1() { Action <Session> removeAction = session => { var reference = new ReferencingEntity4(); new ReferencedEntity4 { Items = { reference } }; reference.Remove(); }; EventHandler <EntityRemovingEventArgs> handler = (s, e) => { var expectedReason = e.Entity is ReferencingEntity4 ? EntityRemoveReason.User : EntityRemoveReason.Association; Assert.That(e.Reason, Is.EqualTo(expectedReason)); }; var affectedEntities = TestEntityRemove(removeAction, handler); Assert.That(affectedEntities, Is.EqualTo(2)); }
public void EntitySetItemRemovalTest2() { Action <Session> removeAction = session => { var referencing = new ReferencingEntity4(); var referenced = new ReferencedEntity4 { Items = { referencing } }; referenced.Items.Remove(referencing); }; EventHandler <EntityRemovingEventArgs> handler = (s, e) => { // no entity should be removed throw new Exception(); }; var affectedEntities = TestEntityRemove(removeAction, handler); Assert.That(affectedEntities, Is.EqualTo(0)); }