Esempio n. 1
0
        public void VerifyHistoryOfOwning()
        {
            var owned1 = new OneToOneOwnedEntity {
                Id = id, Data = "1"
            };
            var owned2 = new OneToOneOwnedEntity {
                Id = id, Data = "2"
            };

            AuditReader().Find <OneToOneOwningEntity>(id, 1).Owned
            .Should().Be.Null();
            AuditReader().Find <OneToOneOwningEntity>(id, 2).Owned
            .Should().Be.EqualTo(owned1);
            AuditReader().Find <OneToOneOwningEntity>(id, 3).Owned
            .Should().Be.EqualTo(owned2);
            AuditReader().Find <OneToOneOwningEntity>(id, 4).Owned
            .Should().Be.Null();
        }
Esempio n. 2
0
        protected override void Initialize()
        {
            var owning = new OneToOneOwningEntity {
                Id = id
            };
            var owned1 = new OneToOneOwnedEntity {
                Data = "1"
            };
            var owned2 = new OneToOneOwnedEntity {
                Data = "2"
            };

            //revision 1 - owning with no owned
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(owning);
                tx.Commit();
            }
            //revision 2 - setting owned 1
            using (var tx = Session.BeginTransaction())
            {
                owned1.Owning = owning;
                Session.Save(owned1);
                tx.Commit();
            }
            //revision 3 - setting owned 2
            using (var tx = Session.BeginTransaction())
            {
                owned2.Owning = owning;
                Session.Delete(owned1);
                Session.Save(owned2);
                tx.Commit();
            }
            //revision 4 - no owned
            using (var tx = Session.BeginTransaction())
            {
                Session.Delete(owned2);                 //actually the same as owned1 in db
                tx.Commit();
            }
        }