Exemple #1
0
        protected override void Initialize()
        {
            var child = new StrTestEntity {
                Str = "data"
            };
            var parent = new ListRefCollEntity {
                Id = parentId, Data = "initial data", Collection = new List <StrTestEntity> {
                    child
                }
            };

            //Revision 1
            using (var tx = Session.BeginTransaction())
            {
                childId = (int)Session.Save(child);
                Session.Save(parent);
                tx.Commit();
            }
            ForceNewSession();
            //Revision 2
            using (var tx = Session.BeginTransaction())
            {
                parent.Data = "modified data";
                Session.Update(parent);
                tx.Commit();
            }
        }
Exemple #2
0
		public void VerifyHistoryOfParent()
		{
			var parent = new ListRefCollEntity
			             	{
			             		Id = parentId,
			             		Data = "initial data",
			             		Collection = new List<StrTestEntity> {new StrTestEntity {Id = childId, Str = "data"}}
			             	};
			
			var ver1 = AuditReader().Find<ListRefCollEntity>(parentId, 1);
			ver1.Should().Be.EqualTo(parent);
			ver1.Collection.Should().Have.SameValuesAs(parent.Collection);

			parent.Data = "modified data";
			var ver2 = AuditReader().Find<ListRefCollEntity>(parentId, 2);
			ver2.Should().Be.EqualTo(parent);
			ver1.Collection.Should().Have.SameValuesAs(parent.Collection);
		}
        protected override void Initialize()
        {
            var str1 = new StrTestEntity {
                Str = "str1"
            };
            var str2 = new StrTestEntity {
                Str = "str2"
            };
            var coll1 = new ListRefCollEntity {
                Id = coll1_id, Data = "coll1"
            };

            using (var tx = Session.BeginTransaction())
            {
                str1_id          = (int)Session.Save(str1);
                str2_id          = (int)Session.Save(str2);
                coll1.Collection = new List <StrTestEntity> {
                    str1
                };
                Session.Save(coll1);
                tx.Commit();
            }
            using (var tx = Session.BeginTransaction())
            {
                coll1.Collection.Add(str2);
                tx.Commit();
            }
            using (var tx = Session.BeginTransaction())
            {
                coll1.Collection.Remove(str1);
                tx.Commit();
            }
            using (var tx = Session.BeginTransaction())
            {
                coll1.Collection.Clear();
                tx.Commit();
            }
        }