Example #1
0
        public void OneToManyRemovalTest2()
        {
            Action <Session> removeAction = session => {
                var reference = new ReferencingEntity5();
                new ReferencedEntity5 {
                    Items = { reference }
                }.Remove();
            };

            EventHandler <EntityRemovingEventArgs> handler = (s, e) => {
                var expectedReason = e.Entity is ReferencedEntity5 ? EntityRemoveReason.User : EntityRemoveReason.Association;
                Assert.That(e.Reason, Is.EqualTo(expectedReason));
            };

            TestEntityRemove(removeAction, handler);
        }
Example #2
0
        public void EntitySetItemRemovalTest3()
        {
            Action <Session> removeAction = session => {
                var referencing = new ReferencingEntity5();
                var referenced  = new ReferencedEntity5 {
                    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));
        }