Example #1
0
        public void UpgradeDeletedInlineObjectWorks()
        {
            var typeNameWfd  = _db.RegisterType(typeof(ObjectWfd1));
            var typeNameRule = _db.RegisterType(typeof(Rule1));

            using (var tr = _db.StartTransaction())
            {
                var wfd = tr.Singleton <ObjectWfd1>();
                wfd.A = new Rule1 {
                    Name = "A"
                };
                wfd.B = new Rule1 {
                    Name = "B"
                };
                wfd.C = new Rule1 {
                    Name = "C"
                };
                tr.Commit();
            }
            ReopenDb();
            _db.RegisterType(typeof(ObjectWfd2), typeNameWfd);
            _db.RegisterType(typeof(Rule2), typeNameRule);

            using (var tr = _db.StartTransaction())
            {
                var wfd = tr.Singleton <ObjectWfd2>();
                wfd.C.Type = 2;
                tr.Store(wfd);
                tr.Commit();
            }
            IterateWithApprove();
        }
Example #2
0
        public void NewObjectCreatedByIocWorks()
        {
            using var tr = _db.StartTransaction();
            _db.RegisterType(typeof(Item));
            var item = tr.New <Item>();

            Assert.Equal("Hello", item.Param);
        }
Example #3
0
 public DBObjectFieldHandler(IObjectDB objectDB, Type type)
 {
     _objectDB = objectDB;
     _type = Unwrap(type);
     _indirect = _type != type;
     _typeName = _objectDB.RegisterType(_type);
     var writer = new ByteBufferWriter();
     writer.WriteString(_typeName);
     _configuration = writer.Data.ToByteArray();
 }
Example #4
0
        public DBObjectFieldHandler(IObjectDB objectDB, Type type)
        {
            _objectDB = objectDB;
            _type     = Unwrap(type);
            _indirect = _type != type;
            _typeName = _objectDB.RegisterType(_type);
            var writer = new ByteBufferWriter();

            writer.WriteString(_typeName);
            _configuration = writer.Data.ToByteArray();
        }
Example #5
0
        public void PersonUpgrade()
        {
            var personObjDBName = _db.RegisterType(typeof(IPerson));

            using (var tr = _db.StartTransaction())
            {
                var p = tr.Insert <IPerson>();
                p.Name = "Bobris";
                p.Age  = 35;
                tr.Commit();
            }
            ReopenDB();
            _db.RegisterType(typeof(IPersonNew), personObjDBName);
            using (var tr = _db.StartTransaction())
            {
                var p = tr.Enumerate <IPersonNew>().First();
                Assert.AreEqual("Bobris", p.Name);
                Assert.AreEqual(35, p.Age);
                Assert.AreEqual(null, p.Comment);
            }
        }
        public void FreeWorksAlsoForDifferentSubObjects()
        {
            _db.RegisterType(typeof(NodesA));
            _db.RegisterType(typeof(NodesB));

            using (var tr = _db.StartTransaction())
            {
                var creator = tr.InitRelation <IGraph>("Graph");
                var table   = creator(tr);
                var graph   = new Graph
                {
                    Id    = 1,
                    Nodes = new NodesA {
                        A = new Dictionary <ulong, ulong> {
                            [0] = 1, [1] = 2, [2] = 3
                        }, F = "f"
                    }
                };
                table.Insert(graph);
                graph = new Graph
                {
                    Id    = 2,
                    Nodes = new NodesB {
                        B = new Dictionary <ulong, ulong> {
                            [0] = 1, [1] = 2, [2] = 3
                        }, E = "e"
                    }
                };
                table.Insert(graph);

                Assert.True(table.FindById(1).Nodes is NodesA);
                Assert.True(table.FindById(2).Nodes is NodesB);

                table.RemoveById(1);
                table.RemoveById(2);
                tr.Commit();
            }
            AssertNoLeaksInDb();
        }
Example #7
0
        public void MaterializesInlineObjectProperty()
        {
            ulong oid;

            using (var tr = _db.StartTransaction())
            {
                oid = tr.Store(new Parent {
                    Child = new DerivedChild {
                        Id = 1
                    }
                });
                tr.Commit();
            }
            ReopenDb();
            _db.RegisterType(typeof(ParentNewVersion), "Parent");
            _db.RegisterType(typeof(DerivedChild));
            _db.RegisterType(typeof(Child));
            using (var tr = _db.StartReadOnlyTransaction())
            {
                var parent = (ParentNewVersion)tr.Get(oid);
                Assert.NotNull(parent.Child);
                Assert.Equal(1ul, parent.Child.Id);
            }
        }