Пример #1
0
        public void SingleRelationshipSavesAndDeletes()
        {
            _testName = System.Reflection.MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();

            var seed = new Seed32();
            List<MockClassE> objs = null;
            var ids = new List<int>();

            using (var fLock = new ManagedFileLock(_testName))
            {
                Cleanup();

                using (var db = new RelationalDatabase<int, MockClassD>(_testName + ".database", "Id"))
                {
                    db.Load();

                    using (var t = db.BeginTransaction())
                    {
                        objs = TestResourceFactory.GetMockClassDObjects(3, db).ToList();

                        objs.ToList().ForEach(o => o.Id = db.Add(o));

                        t.Commit();
                    }
                }

                using (var db = new RelationalDatabase<int, MockClassD>(_testName + ".database"))
                {
                    db.Load();

                    var first = db.Fetch(objs[0].Id);

                    using (var t = db.BeginTransaction())
                    {
                        first.LowBall = new List<MockClassD>();

                        db.Update(first, first.Id);

                        t.Commit();
                    }

                    first = db.Fetch(objs[0].Id);

                    Assert.AreEqual(0, first.LowBall.Count());
                }

                using (var db = new RelationalDatabase<int, MockClassD>(_testName + ".database"))
                {
                    db.Load();

                    var first = db.Fetch(objs.First().Id);

                    Assert.AreEqual(0, first.LowBall.Count());
                }
            }
        }