Esempio n. 1
0
        public void ExceptionFlushingAnExistingObjectWillNotStopVsIncrementOfChildObject()
        {
            Guid id = DbFixture.InsertCustomerWithAddress();
            var  c  = Nh.CurrentSession.Get <Customer>(id);

            Address a = c.AddressAt(0);

            a.Line1 = "Another street";

            c.ShortCode = "CCCCCCCCC"; //update will fail when saved to the db

            int versionPropertyBeforeFlush = a.ConcurrencyId;

            CommitSessionExpectingException();

            Assert.That(a.ConcurrencyId,
                        Is.EqualTo(versionPropertyBeforeFlush + 1),
                        "version property incremented");
        }
Esempio n. 2
0
        public void CanRetryDeletionOfOrphanUsingAnotherSession()
        {
            //setup - trigger an exception when updating...

            Guid customerId = DbFixture.InsertCustomerWithAddress();

            var  c         = Nh.CurrentSession.Get <Customer>(customerId);
            Guid addressID = c.AddressAt(0).Id;

            c.ShortCode = "12345678"; //update will fail when saved to the db
            c.RemoveAddress(c.AddressAt(0));

            CommitSessionExpectingException();

            Assert.That(DbFixture.AddressExits(addressID), Is.True, "address not deleted");

            //run test...

            c.ShortCode = "ABCDE"; //correct problem that was causing save to fail

            PersistUsingNewSession(c);

            Assert.That(DbFixture.AddressExits(addressID), Is.False, "address is deleted");
        }
Esempio n. 3
0
        public void CanRetryUpdateOfChild()
        {
            //setup...

            Guid id = DbFixture.InsertCustomerWithAddress();
            var  c  = Nh.CurrentSession.Get <Customer>(id);

            Address a = c.AddressAt(0);

            a.Line1 = "Another street";

            c.ShortCode = "CCCCCCCCC"; //update will fail when saved to the db

            CommitSessionExpectingException();

            //run test...

            c.ShortCode = "ABCDE"; //correct problem that was causing save to fail
            ResetVersionPropertyTo(a, 1);

            PersistUsingNewSession(c);

            Assert.That(c.ConcurrencyId, Is.EqualTo(2), "ConcurrencyId correctly incremented");
        }