public void FreeIDictionaryInList()
        {
            Func <IObjectDBTransaction, ILinksInList> creator;

            using (var tr = _db.StartTransaction())
            {
                creator = tr.InitRelation <ILinksInList>("ListLinksRelation");
                var links = creator(tr);
                var link  = new LinkInList
                {
                    Id        = 1,
                    EdgesList = new List <IDictionary <ulong, ulong> >
                    {
                        new Dictionary <ulong, ulong> {
                            [0] = 1, [1] = 2, [2] = 3
                        },
                        new Dictionary <ulong, ulong> {
                            [0] = 1, [1] = 2, [2] = 3
                        }
                    }
                };
                links.Insert(link);
                tr.Commit();
            }
            AssertNoLeaksInDb();
            using (var tr = _db.StartTransaction())
            {
                var links = creator(tr);

                Assert.True(links.RemoveById(1));
                tr.Commit();
            }
            AssertNoLeaksInDb();
        }
Esempio n. 2
0
        public void FreeIDictionaryInListInUpdate()
        {
            Func <IObjectDBTransaction, ILinksInList> creator;

            using (var tr = _db.StartTransaction())
            {
                creator = tr.InitRelation <ILinksInList>("ListLinksRelation");
                var links = creator(tr);
                var link  = new LinkInList
                {
                    Id        = 1,
                    EdgesList = new List <IDictionary <ulong, ulong> >
                    {
                        new Dictionary <ulong, ulong> {
                            [0] = 1, [1] = 2, [2] = 3
                        },
                        new Dictionary <ulong, ulong> {
                            [0] = 1, [1] = 2, [2] = 3
                        }
                    }
                };
                links.Insert(link);
                tr.Commit();
            }

            AssertNoLeaksInDb();
            using (var tr = _db.StartTransaction())
            {
                var links = creator(tr);
                var link  = links.FindById(1);
                for (int i = 0; i < 20; i++)
                {
                    link.EdgesList.Add(new Dictionary <ulong, ulong> {
                        [10] = 20
                    });
                }
                links.Update(link);
                tr.Commit();
            }

            AssertNoLeaksInDb();
        }
 public void FreeIDictionaryInListInUpdate()
 {
     Func<IObjectDBTransaction, ILinksInList> creator;
     using (var tr = _db.StartTransaction())
     {
         creator = tr.InitRelation<ILinksInList>("ListLinksRelation");
         var links = creator(tr);
         var link = new LinkInList
         {
             Id = 1,
             EdgesList = new List<IDictionary<ulong, ulong>>
             {
                 new Dictionary<ulong, ulong> { [0] = 1, [1] = 2, [2] = 3 } ,
                 new Dictionary<ulong, ulong> { [0] = 1, [1] = 2, [2] = 3 }
             }
         };
         links.Insert(link);
         tr.Commit();
     }
     AssertNoLeaksInDb();
     using (var tr = _db.StartTransaction())
     {
         var links = creator(tr);
         var link = links.FindById(1);
         for (int i = 0; i < 20; i++)
             link.EdgesList.Add(new Dictionary<ulong, ulong> { [10] = 20 });
         links.Update(link);
         tr.Commit();
     }
     AssertNoLeaksInDb();
 }
        public void FreeIDictionaryInList()
        {
            Func<IObjectDBTransaction, ILinksInList> creator;
            using (var tr = _db.StartTransaction())
            {
                creator = tr.InitRelation<ILinksInList>("ListLinksRelation");
                var links = creator(tr);
                var link = new LinkInList
                {
                    Id = 1,
                    EdgesList = new List<IDictionary<ulong, ulong>>
                    {
                        new Dictionary<ulong, ulong> { [0] = 1, [1] = 2, [2] = 3 } ,
                        new Dictionary<ulong, ulong> { [0] = 1, [1] = 2, [2] = 3 }
                    }
                };
                links.Insert(link);
                tr.Commit();
            }
            AssertNoLeaksInDb();
            using (var tr = _db.StartTransaction())
            {
                var links = creator(tr);

                Assert.True(links.RemoveById(1));
                tr.Commit();
            }
            AssertNoLeaksInDb();
        }