Пример #1
0
        public void Create2ObjectCircularReference()
        {
            int pA = DataUtil.CountRows("ParentA");
            int pB = DataUtil.CountRows("ParentB");
            int cA = DataUtil.CountRows("ChildA");

            ObjectTransaction transaction = manager.BeginTransaction();

            ParentBTestObject parentB = transaction.Select(typeof(ParentBTestObject), 43) as ParentBTestObject;

            ParentATestObject parentA = transaction.Create(typeof(ParentATestObject)) as ParentATestObject;

            parentA.ObjData = "A";
            parentA.ParentB = parentB;

            ChildATestObject childA = transaction.Create(typeof(ChildATestObject)) as ChildATestObject;

            childA.ParentA = parentA;
            childA.ParentB = parentB;

            transaction.Commit();

            Assert.AreEqual(pA + 1, DataUtil.CountRows("ParentA"));
            Assert.AreEqual(pB, DataUtil.CountRows("ParentB"));
            Assert.AreEqual(cA + 1, DataUtil.CountRows("ChildA"));
        }
Пример #2
0
        public void InsertParentChild()
        {
            int parentCount   = DataUtil.CountRows("DefinedParents");
            int childrenCount = DataUtil.CountRows("DefinedChildren");

            ObjectTransaction transaction = manager.BeginTransaction();

            DefinedParentTestObject parent = transaction.Create(typeof(DefinedParentTestObject), "Key6") as DefinedParentTestObject;

            parent.ObjData = "XXX";
            Assert.AreEqual(0, parent.ChildObjects.Count);

            for (int i = 0; i < 10; i++)
            {
                DefinedChildTestObject child = transaction.Create(typeof(DefinedChildTestObject), i) as DefinedChildTestObject;
                child.ObjData = i.ToString();
                child.Parent  = parent;
            }

            Assert.AreEqual(10, parent.ChildObjects.Count);

            transaction.Commit();

            Assert.AreEqual(parentCount + 1, DataUtil.CountRows("DefinedParents"));
            Assert.AreEqual(childrenCount + 10, DataUtil.CountRows("DefinedChildren"));
        }
Пример #3
0
        public void Insert()
        {
            int count = DataUtil.CountRows("IdentityKeys");

            ObjectTransaction transaction = manager.BeginTransaction();

            IdentityKeyTestObject test1 = transaction.Create(typeof(IdentityKeyTestObject)) as IdentityKeyTestObject;

            Assert.AreEqual(-1, test1.Id);

            test1.ObjData = "test";

            transaction.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("IdentityKeys"));

            IdentityKeyTestObject test2 = transaction.Create(typeof(IdentityKeyTestObject)) as IdentityKeyTestObject;

            Assert.AreEqual(-2, test2.Id);

            test2.ObjData = "test1";

            transaction.Commit();

            Assert.AreEqual(test2.Id, test1.Id + 1);

            Assert.AreEqual(count + 2, DataUtil.CountRows("IdentityKeys"));
        }
Пример #4
0
        public void Create()
        {
            int count = DataUtil.CountRows("IdentityKeys");

            ObjectTransaction transaction = manager.BeginTransaction();

            IdentityKeyTestObject test1 = transaction.Create(typeof(IdentityKeyTestObject)) as IdentityKeyTestObject;
            IdentityKeyTestObject test2 = transaction.Create(typeof(IdentityKeyTestObject)) as IdentityKeyTestObject;

            Assert.AreEqual(-1, test1.Id);
            Assert.AreEqual(-2, test2.Id);

            Assert.AreEqual(count, DataUtil.CountRows("IdentityKeys"));
        }
Пример #5
0
        public void AddChild()
        {
            int parentCount   = DataUtil.CountRows("GuidParents");
            int childrenCount = DataUtil.CountRows("GuidChildren");

            ObjectTransaction transaction = manager.BeginTransaction();

            CascadeGuidParentTestObject parent = transaction.Select(typeof(CascadeGuidParentTestObject), "{F9643D1E-9FAC-4C01-B535-D2B0D2F582E7}") as CascadeGuidParentTestObject;

            Assert.AreEqual(new Guid("{F9643D1E-9FAC-4C01-B535-D2B0D2F582E7}"), parent.Id);
            Assert.AreEqual("Y", parent.ObjData);
            Assert.AreEqual(0, parent.ChildObjects.Count);

            CascadeGuidChildTestObject child = transaction.Create(typeof(CascadeGuidChildTestObject)) as CascadeGuidChildTestObject;

            child.ObjData = "test";
            child.Parent  = parent;

            Assert.AreEqual(new Guid("{F9643D1E-9FAC-4C01-B535-D2B0D2F582E7}"), child.Parent.Id);
            Assert.AreEqual(1, parent.ChildObjects.Count);

            Assert.IsTrue(parent.ChildObjects.Contains(child));

            transaction.Commit();

            Assert.AreEqual(parentCount, DataUtil.CountRows("GuidParents"));
            Assert.AreEqual(childrenCount + 1, DataUtil.CountRows("GuidChildren"));
        }
        public void Delete()
        {
            int count = DataUtil.CountRows("DefinedKeys");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            DefinedKeyTestObject test1 = transaction1.Create(typeof(DefinedKeyTestObject), "defined10") as DefinedKeyTestObject;

            Assert.AreEqual("defined10", test1.Id);

            test1.ObjData = 101;
            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("DefinedKeys"));

            ObjectTransaction transaction2 = manager.BeginTransaction();

            DefinedKeyTestObject test2 = transaction2.Select(typeof(DefinedKeyTestObject), "defined10") as DefinedKeyTestObject;

            Assert.AreEqual("defined10", test2.Id);
            Assert.AreEqual(101, test2.ObjData);

            transaction2.Delete(test2);

            transaction2.Commit();

            Assert.AreEqual(count, DataUtil.CountRows("DefinedKeys"));
        }
        public void DeleteRandomValues()
        {
            int count = DataUtil.CountRows("NullableIntegers");

            ObjectTransaction         transaction1 = manager.BeginTransaction();
            NullableIntegerTestObject test1        = transaction1.Create(typeof(NullableIntegerTestObject)) as NullableIntegerTestObject;

            test1.Boolean  = true;
            test1.TinyInt  = 5;
            test1.Int      = 12457;
            test1.SmallInt = 124;
            test1.BigInt   = 1234567;
            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("NullableIntegers"));

            ObjectTransaction         transaction2 = manager.BeginTransaction();
            NullableIntegerTestObject test2        = transaction2.Select(typeof(NullableIntegerTestObject), test1.Id) as NullableIntegerTestObject;

            Assert.AreEqual(true, test2.Boolean);
            Assert.AreEqual(5, test2.TinyInt);
            Assert.AreEqual(124, test2.SmallInt);
            Assert.AreEqual(12457, test1.Int);
            Assert.AreEqual(1234567, test2.BigInt);

            transaction2.Delete(test2);
            transaction2.Commit();

            Assert.AreEqual(count, DataUtil.CountRows("NullableIntegers"));
        }
        public void InsertNullExplicitValues()
        {
            int count = DataUtil.CountRows("NullableIntegers");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            NullableIntegerTestObject test1 = transaction1.Create(typeof(NullableIntegerTestObject)) as NullableIntegerTestObject;

            test1.Boolean  = false;
            test1.TinyInt  = 1;
            test1.SmallInt = -1;
            test1.Int      = -2;
            test1.BigInt   = -3;

            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("NullableIntegers"));
            Assert.IsTrue(DataUtil.IsRowNull("NullableIntegers", "id", test1.Id));

            ObjectTransaction transaction2 = manager.BeginTransaction();

            NullableIntegerTestObject test2 = transaction2.Select(typeof(NullableIntegerTestObject), test1.Id) as NullableIntegerTestObject;


            Assert.AreEqual(false, test2.Boolean);
            Assert.AreEqual(1, test2.TinyInt);
            Assert.AreEqual(-1, test2.SmallInt);
            Assert.AreEqual(-2, test2.Int);
            Assert.AreEqual(-3, test2.BigInt);
        }
        public void InsertNullExplicitValues()
        {
            int count = DataUtil.CountRows("NullableFloatingPointNumbers");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            NullableFloatingPointNumberTestObject test1 = transaction1.Create(typeof(NullableFloatingPointNumberTestObject)) as NullableFloatingPointNumberTestObject;

            test1.Decimal    = -1;
            test1.Numeric    = -1;
            test1.Float      = Double.MinValue;
            test1.Real       = Single.MinValue;
            test1.Money      = -1;
            test1.SmallMoney = -1;

            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("NullableFloatingPointNumbers"));
            Assert.IsTrue(DataUtil.IsRowNull("NullableFloatingPointNumbers", "id", test1.Id));

            ObjectTransaction transaction2 = manager.BeginTransaction();

            NullableFloatingPointNumberTestObject test2 = transaction2.Select(typeof(NullableFloatingPointNumberTestObject), test1.Id) as NullableFloatingPointNumberTestObject;

            Assert.AreEqual(-1, test2.Decimal);
            Assert.AreEqual(-1, test2.Numeric);
            Assert.AreEqual(Double.MinValue, test2.Float);
            Assert.AreEqual(Single.MinValue, test2.Real);
            Assert.AreEqual(-1, test2.Money);
            Assert.AreEqual(-1, test2.SmallMoney);
        }
Пример #10
0
        public void DeleteRandomValues()
        {
            int count = DataUtil.CountRows("NullableCharacters");

            ObjectTransaction           transaction1 = manager.BeginTransaction();
            NullableCharacterTestObject test1        = transaction1.Create(typeof(NullableCharacterTestObject)) as NullableCharacterTestObject;

            test1.Char   = "z";
            test1.NChar  = "z";
            test1.VChar  = "zzz";
            test1.NVChar = "zzz";
            test1.Text   = "zzz";
            test1.NText  = "zzz";

            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("NullableCharacters"));

            ObjectTransaction           transaction2 = manager.BeginTransaction();
            NullableCharacterTestObject test2        = transaction2.Select(typeof(NullableCharacterTestObject), test1.Id) as NullableCharacterTestObject;

            Assert.AreEqual(test1.Id, test2.Id);
            Assert.AreEqual("z", test2.Char);
            Assert.AreEqual("z", test2.NChar);
            Assert.AreEqual("zzz", test2.VChar);
            Assert.AreEqual("zzz", test2.NVChar);
            Assert.AreEqual("zzz", test2.Text);
            Assert.AreEqual("zzz", test2.NText);

            transaction2.Delete(test2);
            transaction2.Commit();

            Assert.AreEqual(count, DataUtil.CountRows("NullableCharacters"));
        }
Пример #11
0
        public void InsertNullExplicitValues()
        {
            int count = DataUtil.CountRows("NullableCharacters");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            NullableCharacterTestObject test1 = transaction1.Create(typeof(NullableCharacterTestObject)) as NullableCharacterTestObject;

            test1.Char   = "x";
            test1.NChar  = "z";
            test1.VChar  = "<null value>";
            test1.NVChar = "<null n value>";
            test1.Text   = "<null text value>";
            test1.NText  = "<null ntext value>";

            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("NullableCharacters"));
            Assert.IsTrue(DataUtil.IsRowNull("NullableCharacters", "id", test1.Id));

            ObjectTransaction transaction2 = manager.BeginTransaction();

            NullableCharacterTestObject test2 = transaction2.Select(typeof(NullableCharacterTestObject), test1.Id) as NullableCharacterTestObject;

            Assert.AreEqual("x", test2.Char);
            Assert.AreEqual("z", test2.NChar);
            Assert.AreEqual("<null value>", test2.VChar);
            Assert.AreEqual("<null n value>", test2.NVChar);
            Assert.AreEqual("<null text value>", test2.Text);
            Assert.AreEqual("<null ntext value>", test2.NText);
        }
Пример #12
0
        public void DeleteRandomValues()
        {
            int count = DataUtil.CountRows("Integers");

            ObjectTransaction transaction1 = manager.BeginTransaction();
            IntegerTestObject test1        = transaction1.Create(typeof(IntegerTestObject)) as IntegerTestObject;

            test1.Boolean  = false;
            test1.TinyInt  = 1;
            test1.Int      = 123;
            test1.SmallInt = 56;
            test1.BigInt   = 169;

            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("Integers"));

            ObjectTransaction transaction2 = manager.BeginTransaction();
            IntegerTestObject test2        = transaction2.Select(typeof(IntegerTestObject), test1.Id) as IntegerTestObject;

            Assert.AreEqual(false, test2.Boolean);
            Assert.AreEqual(1, test2.TinyInt);
            Assert.AreEqual(123, test2.Int);
            Assert.AreEqual(56, test2.SmallInt);
            Assert.AreEqual(169, test2.BigInt);

            transaction2.Delete(test2);
            transaction2.Commit();

            Assert.AreEqual(count, DataUtil.CountRows("Integers"));
        }
Пример #13
0
        public void DeleteRandomValues()
        {
            Random random = new Random();

            int count = DataUtil.CountRows("Binary");

            ObjectTransaction transaction = manager.BeginTransaction();

            BinaryTestObject test1 = transaction.Create(typeof(BinaryTestObject)) as BinaryTestObject;

            test1.Binary = new byte[8];
            random.NextBytes(test1.Binary);

            test1.VarBinary = new byte[5];
            random.NextBytes(test1.VarBinary);

            test1.Image = new byte[1024];
            random.NextBytes(test1.Image);

            transaction.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("Binary"));

            ObjectTransaction transaction2 = manager.BeginTransaction();
            BinaryTestObject  test2        = transaction2.Select(typeof(BinaryTestObject), test1.Id) as BinaryTestObject;

            Assert.AreEqual(8, test2.Binary.Length);
            Assert.AreEqual(5, test2.VarBinary.Length);
            Assert.AreEqual(1024, test2.Image.Length);

            transaction2.Delete(test2);
            transaction2.Commit();

            Assert.AreEqual(count, DataUtil.CountRows("Binary"));
        }
        public void DeleteRandomValues()
        {
            int count = DataUtil.CountRows("NullableDateTimes");

            ObjectTransaction          transaction1 = manager.BeginTransaction();
            NullableDateTimeTestObject test1        = transaction1.Create(typeof(NullableDateTimeTestObject)) as NullableDateTimeTestObject;

            test1.Date      = DateTime.Today.AddDays(-30);
            test1.SmallDate = DateTime.Today.AddMonths(1);

            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("NullableDateTimes"));

            ObjectTransaction          transaction2 = manager.BeginTransaction();
            NullableDateTimeTestObject test2        = transaction2.Select(typeof(NullableDateTimeTestObject), test1.Id) as NullableDateTimeTestObject;

            Assert.AreEqual(DateTime.Today.AddDays(-30), test2.Date);
            Assert.AreEqual(DateTime.Today.AddMonths(1), test2.SmallDate);

            transaction2.Delete(test2);
            transaction2.Commit();

            Assert.AreEqual(count, DataUtil.CountRows("NullableDateTimes"));
        }
        public void DeleteRandomValues()
        {
            int count = DataUtil.CountRows("FloatingPointNumbers");

            ObjectTransaction             transaction1 = manager.BeginTransaction();
            FloatingPointNumberTestObject test1        = transaction1.Create(typeof(FloatingPointNumberTestObject)) as FloatingPointNumberTestObject;

            test1.Decimal    = 1.565m;
            test1.Numeric    = 565m;
            test1.Float      = -1.25;
            test1.Real       = 126;
            test1.Money      = -65.65m;
            test1.SmallMoney = 23.545m;

            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("FloatingPointNumbers"));

            ObjectTransaction             transaction2 = manager.BeginTransaction();
            FloatingPointNumberTestObject test2        = transaction2.Select(typeof(FloatingPointNumberTestObject), test1.Id) as FloatingPointNumberTestObject;

            Assert.AreEqual(2, test2.Decimal);
            Assert.AreEqual(565, test2.Numeric);
            Assert.AreEqual(-1.25, test2.Float);
            Assert.AreEqual(126, test2.Real);
            Assert.AreEqual(-65.65m, test2.Money);
            Assert.AreEqual(23.545m, test2.SmallMoney);

            transaction2.Delete(test2);
            transaction2.Commit();

            Assert.AreEqual(count, DataUtil.CountRows("FloatingPointNumbers"));
        }
Пример #16
0
        public void Delete()
        {
            int count = DataUtil.CountRows("GuidKeys");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            GuidKeyTestObject test1 = transaction1.Create(typeof(GuidKeyTestObject)) as GuidKeyTestObject;

            test1.ObjData = 169;
            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("GuidKeys"));

            ObjectTransaction transaction2 = manager.BeginTransaction();

            GuidKeyTestObject test2 = transaction2.Select(typeof(GuidKeyTestObject), test1.Id) as GuidKeyTestObject;

            Assert.AreEqual(test1.Id, test2.Id);
            Assert.AreEqual(169, test2.ObjData);

            transaction2.Delete(test2);

            transaction2.Commit();

            Assert.AreEqual(count, DataUtil.CountRows("GuidKeys"));
        }
Пример #17
0
        public void Delete()
        {
            int count = DataUtil.CountRows("IdentityKeys");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            IdentityKeyTestObject test1 = transaction1.Create(typeof(IdentityKeyTestObject)) as IdentityKeyTestObject;

            Assert.AreEqual(-1, test1.Id);

            test1.ObjData = "blah";
            transaction1.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("IdentityKeys"));

            ObjectTransaction transaction2 = manager.BeginTransaction();

            IdentityKeyTestObject test2 = transaction2.Select(typeof(IdentityKeyTestObject), test1.Id) as IdentityKeyTestObject;

            Assert.AreEqual(test1.Id, test2.Id);
            Assert.AreEqual("blah", test2.ObjData);

            transaction2.Delete(test2);

            transaction2.Commit();

            Assert.AreEqual(count, DataUtil.CountRows("IdentityKeys"));
        }
Пример #18
0
        public void AddChild()
        {
            int parentCount   = DataUtil.CountRows("DefinedParents");
            int childrenCount = DataUtil.CountRows("DefinedChildren");

            ObjectTransaction transaction = manager.BeginTransaction();

            DefinedParentTestObject parent = transaction.Select(typeof(DefinedParentTestObject), "Key2") as DefinedParentTestObject;

            Assert.AreEqual("Key2", parent.Id);
            Assert.AreEqual("Data2", parent.ObjData);
            Assert.AreEqual(0, parent.ChildObjects.Count);

            DefinedChildTestObject child = transaction.Create(typeof(DefinedChildTestObject), "CK1") as DefinedChildTestObject;

            child.ObjData = "test";
            child.Parent  = parent;

            Assert.AreEqual("Key2", child.Parent.Id);
            Assert.AreEqual(1, parent.ChildObjects.Count);

            Assert.IsTrue(parent.ChildObjects.Contains(child));

            transaction.Commit();

            Assert.AreEqual(parentCount, DataUtil.CountRows("DefinedParents"));
            Assert.AreEqual(childrenCount + 1, DataUtil.CountRows("DefinedChildren"));
        }
Пример #19
0
        public void AddChild()
        {
            int parentCount   = DataUtil.CountRows("IdentityParents");
            int childrenCount = DataUtil.CountRows("IdentityChildren");

            ObjectTransaction transaction = manager.BeginTransaction();

            IdentityParentTestObject parent = transaction.Select(typeof(IdentityParentTestObject), 4) as IdentityParentTestObject;

            Assert.AreEqual(4, parent.Id);
            Assert.AreEqual("B", parent.ObjData);
            Assert.AreEqual(0, parent.ChildObjects.Count);

            IdentityChildTestObject child = transaction.Create(typeof(IdentityChildTestObject)) as IdentityChildTestObject;

            child.ObjData = "test";
            child.Parent  = parent;

            Assert.AreEqual(4, child.Parent.Id);
            Assert.AreEqual(1, parent.ChildObjects.Count);

            Assert.IsTrue(parent.ChildObjects.Contains(child));

            transaction.Commit();

            Assert.AreEqual(parentCount, DataUtil.CountRows("IdentityParents"));
            Assert.AreEqual(childrenCount + 1, DataUtil.CountRows("IdentityChildren"));
        }
Пример #20
0
        public void InsertChildWithNoParent()
        {
            ObjectTransaction transaction = manager.BeginTransaction();

            CascadeGuidChildTestObject child = transaction.Create(typeof(CascadeGuidChildTestObject)) as CascadeGuidChildTestObject;

            child.ObjData = "test";

            transaction.Commit();
        }
Пример #21
0
        public void CreateWithoutKey()
        {
            int count = DataUtil.CountRows("DefinedKeys");

            ObjectTransaction transaction = manager.BeginTransaction();

            DefinedKeyTestObject test = transaction.Create(typeof(DefinedKeyTestObject)) as DefinedKeyTestObject;

            Assert.AreEqual(count, DataUtil.CountRows("DefinedKeys"));
        }
Пример #22
0
        public void InsertChildWithNoParent()
        {
            ObjectTransaction transaction = manager.BeginTransaction();

            DefinedChildTestObject child = transaction.Create(typeof(DefinedChildTestObject), "TestKey1") as DefinedChildTestObject;

            child.ObjData = "test";

            transaction.Commit();
        }
        public void CreateNullValues()
        {
            int count = DataUtil.CountRows("NullableDateTimes");

            ObjectTransaction transaction = manager.BeginTransaction();

            NullableDateTimeTestObject test = transaction.Create(typeof(NullableDateTimeTestObject)) as NullableDateTimeTestObject;

            Assert.AreEqual(new DateTime(2004, 1, 1), test.Date);
            Assert.AreEqual(new DateTime(1981, 7, 11), test.SmallDate);

            Assert.AreEqual(count, DataUtil.CountRows("NullableDateTimes"));
        }
Пример #24
0
        public void InsertParent()
        {
            int count = DataUtil.CountRows("DefinedParents");

            ObjectTransaction transaction = manager.BeginTransaction();

            CascadeDefinedParentTestObject parent = transaction.Create(typeof(CascadeDefinedParentTestObject), "testkey1") as CascadeDefinedParentTestObject;

            parent.ObjData = "test";
            Assert.AreEqual(0, parent.ChildObjects.Count);
            transaction.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("DefinedParents"));
        }
Пример #25
0
        public void InsertParent()
        {
            int count = DataUtil.CountRows("IdentityParents");

            ObjectTransaction transaction = manager.BeginTransaction();

            IdentityParentTestObject parent = transaction.Create(typeof(IdentityParentTestObject)) as IdentityParentTestObject;

            parent.ObjData = "test";
            Assert.AreEqual(0, parent.ChildObjects.Count);
            transaction.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("IdentityParents"));
        }
        public void InsertChildWithNoParent()
        {
            int count = DataUtil.CountRows("NullGuidChildren");

            ObjectTransaction transaction = manager.BeginTransaction();

            NullGuidChildTestObject child = transaction.Create(typeof(NullGuidChildTestObject)) as NullGuidChildTestObject;

            child.ObjData = "test";

            transaction.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("NullGuidChildren"));
        }
Пример #27
0
        public void InsertChildWithoutParent()
        {
            int count = DataUtil.CountRows("NullChildren");

            ObjectTransaction transaction = manager.BeginTransaction();

            NullChildTestObject obj = transaction.Create(typeof(NullChildTestObject)) as NullChildTestObject;

            obj.Value = 8;

            transaction.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("NullChildren"));
        }
Пример #28
0
        public void Insert()
        {
            int count = DataUtil.CountRows("GuidKeys");

            ObjectTransaction transaction = manager.BeginTransaction();

            GuidKeyTestObject test = transaction.Create(typeof(GuidKeyTestObject)) as GuidKeyTestObject;

            test.ObjData = 69;

            transaction.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("GuidKeys"));
        }
Пример #29
0
        public void InsertMissingValues()
        {
            int count = DataUtil.CountRows("DateTimes");

            ObjectTransaction transaction = manager.BeginTransaction();

            DateTimeTestObject test = transaction.Create(typeof(DateTimeTestObject)) as DateTimeTestObject;

            test.SmallDate = DateTime.Now.AddDays(-1);

            transaction.Commit();

            Assert.AreEqual(count + 1, DataUtil.CountRows("DateTimes"));
        }
Пример #30
0
        public void ShiftToNewParent()
        {
            int parentCount   = DataUtil.CountRows("IdentityParents");
            int childrenCount = DataUtil.CountRows("IdentityChildren");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            IdentityParentTestObject parent1 = transaction1.Select(typeof(IdentityParentTestObject), 3) as IdentityParentTestObject;
            IdentityParentTestObject parent2 = transaction1.Create(typeof(IdentityParentTestObject)) as IdentityParentTestObject;

            parent2.ObjData = "X";

            IdentityChildTestObject child1 = transaction1.Select(typeof(IdentityChildTestObject), 1) as IdentityChildTestObject;

            Assert.AreEqual(1, child1.Id);
            Assert.AreEqual("A", child1.ObjData);
            Assert.AreEqual(3, child1.Parent.Id);
            Assert.IsTrue(child1.Parent.ChildObjects.Contains(child1));
            Assert.AreEqual(parent1, child1.Parent);
            Assert.IsTrue(parent1.ChildObjects.Contains(child1));
            Assert.IsFalse(parent2.ChildObjects.Contains(child1));

            child1.Parent = parent2;

            Assert.AreEqual(1, child1.Id);
            Assert.AreEqual("A", child1.ObjData);
            Assert.AreEqual(-1, child1.Parent.Id);
            Assert.IsTrue(child1.Parent.ChildObjects.Contains(child1));
            Assert.AreEqual(parent2, child1.Parent);
            Assert.IsTrue(parent2.ChildObjects.Contains(child1));
            Assert.IsFalse(parent1.ChildObjects.Contains(child1));

            transaction1.Commit();

            Assert.AreEqual(parentCount + 1, DataUtil.CountRows("IdentityParents"));
            Assert.AreEqual(childrenCount, DataUtil.CountRows("IdentityChildren"));

            ObjectTransaction transaction2 = manager.BeginTransaction();

            IdentityChildTestObject child2 = transaction2.Select(typeof(IdentityChildTestObject), 1) as IdentityChildTestObject;

            Assert.AreEqual(1, child2.Id);
            Assert.AreEqual("A", child2.ObjData);
            Assert.AreEqual("X", child2.Parent.ObjData);

            Assert.AreEqual(parentCount + 1, DataUtil.CountRows("IdentityParents"));
            Assert.AreEqual(childrenCount, DataUtil.CountRows("IdentityChildren"));
        }