Ejemplo n.º 1
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"));
        }
Ejemplo n.º 2
0
        public void DoubleCommit()
        {
            ObjectTransaction          transaction1 = manager.BeginTransaction();
            SimpleConstraintTestObject obj1         = transaction1.Select(typeof(SimpleConstraintTestObject), 1) as SimpleConstraintTestObject;

            obj1.Varchar = "XXX";
            transaction1.Commit();
            obj1.Varchar = "YYY";
            transaction1.Commit();

            ObjectTransaction          transaction2 = manager.BeginTransaction();
            SimpleConstraintTestObject obj2         = transaction2.Select(typeof(SimpleConstraintTestObject), 1) as SimpleConstraintTestObject;

            Assert.AreEqual("YYY", obj2.Varchar);
        }
        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"));
        }
Ejemplo n.º 4
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"));
        }
Ejemplo n.º 5
0
        public void UpdateRandomValues()
        {
            Random random = new Random();

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

            ObjectTransaction transaction = manager.BeginTransaction();

            BinaryTestObject test1 = transaction.Select(typeof(BinaryTestObject), UpdateValue) as BinaryTestObject;

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

            byte b = test1.Binary[3];

            test1.VarBinary[2] = 16;
            test1.Image[1]     = 69;

            transaction.Commit();

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

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

            Assert.AreEqual(b, test2.Binary[3]);
            Assert.AreEqual(16, test2.VarBinary[2]);
            Assert.AreEqual(69, test2.Image[1]);

            transaction2.Commit();

            Assert.AreEqual(count, DataUtil.CountRows("Binary"));
        }
Ejemplo n.º 6
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"));
        }
Ejemplo n.º 7
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"));
        }
Ejemplo n.º 8
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"));
        }
        public void UpdateValues()
        {
            int count = DataUtil.CountRows("NullableIntegers");

            ObjectTransaction transaction = manager.BeginTransaction();

            NullableIntegerTestObject test1 = transaction.Select(typeof(NullableIntegerTestObject), UpdateValue) as NullableIntegerTestObject;

            Assert.AreEqual(true, test1.Boolean);
            Assert.AreEqual(1, test1.TinyInt);
            Assert.AreEqual(1, test1.SmallInt);
            Assert.AreEqual(1, test1.Int);
            Assert.AreEqual(1, test1.BigInt);

            test1.Boolean  = false;
            test1.TinyInt  = 2;
            test1.SmallInt = 3;
            test1.Int      = 4;
            test1.BigInt   = 5;

            transaction.Commit();

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

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

            Assert.AreEqual(false, test2.Boolean);
            Assert.AreEqual(2, test2.TinyInt);
            Assert.AreEqual(3, test2.SmallInt);
            Assert.AreEqual(4, test2.Int);
            Assert.AreEqual(5, test2.BigInt);

            Assert.AreEqual(count, DataUtil.CountRows("NullableIntegers"));
        }
        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);
        }
Ejemplo n.º 13
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"));
        }
Ejemplo n.º 14
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"));
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        public void UpdateChild()
        {
            int parentCount   = DataUtil.CountRows("IdentityParents");
            int childrenCount = DataUtil.CountRows("IdentityChildren");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            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));

            child1.ObjData = "X";

            transaction1.Commit();

            Assert.AreEqual(parentCount, 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("X", child2.ObjData);
            Assert.AreEqual(3, child2.Parent.Id);
            Assert.IsTrue(child2.Parent.ChildObjects.Contains(child2));

            Assert.AreEqual(parentCount, DataUtil.CountRows("IdentityParents"));
            Assert.AreEqual(childrenCount, DataUtil.CountRows("IdentityChildren"));
        }
Ejemplo n.º 17
0
        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"));
        }
Ejemplo n.º 18
0
        public void Update()
        {
            int count = DataUtil.CountRows("DefinedKeys");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            DefinedKeyTestObject test1 = transaction1.Select(typeof(DefinedKeyTestObject), "defined2") as DefinedKeyTestObject;

            Assert.AreEqual("defined2", test1.Id);
            Assert.AreEqual(2, test1.ObjData);

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

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

            ObjectTransaction transaction2 = manager.BeginTransaction();

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

            Assert.AreEqual("defined2", test2.Id);
            Assert.AreEqual(13, test2.ObjData);

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

            ObjectTransaction transaction = manager.BeginTransaction();

            NullableDateTimeTestObject test1 = transaction.Select(typeof(NullableDateTimeTestObject), UpdateValue) as NullableDateTimeTestObject;

            Assert.AreEqual(new DateTime(2003, 10, 23), test1.Date);
            Assert.AreEqual(new DateTime(2003, 10, 23), test1.SmallDate);

            test1.Date      = test1.Date.AddDays(-6);
            test1.SmallDate = test1.SmallDate.AddYears(1);

            transaction.Commit();

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

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

            Assert.AreEqual(new DateTime(2003, 10, 17), test2.Date);
            Assert.AreEqual(new DateTime(2004, 10, 23), test2.SmallDate);

            Assert.AreEqual(count, DataUtil.CountRows("NullableDateTimes"));
        }
Ejemplo n.º 20
0
        public void UpdateChild()
        {
            int parentCount   = DataUtil.CountRows("DefinedParents");
            int childrenCount = DataUtil.CountRows("DefinedChildren");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            DefinedChildTestObject child1 = transaction1.Select(typeof(DefinedChildTestObject), "ChildKey1") as DefinedChildTestObject;

            Assert.AreEqual("ChildKey1", child1.Id);
            Assert.AreEqual("CData1", child1.ObjData);
            Assert.AreEqual("Key1", child1.Parent.Id);
            Assert.IsTrue(child1.Parent.ChildObjects.Contains(child1));

            child1.ObjData = "X";

            transaction1.Commit();

            Assert.AreEqual(parentCount, DataUtil.CountRows("DefinedParents"));
            Assert.AreEqual(childrenCount, DataUtil.CountRows("DefinedChildren"));

            ObjectTransaction transaction2 = manager.BeginTransaction();

            DefinedChildTestObject child2 = transaction2.Select(typeof(DefinedChildTestObject), "ChildKey1") as DefinedChildTestObject;

            Assert.AreEqual("ChildKey1", child2.Id);
            Assert.AreEqual("X", child2.ObjData);
            Assert.AreEqual("Key1", child2.Parent.Id);
            Assert.IsTrue(child2.Parent.ChildObjects.Contains(child2));

            Assert.AreEqual(parentCount, DataUtil.CountRows("DefinedParents"));
            Assert.AreEqual(childrenCount, DataUtil.CountRows("DefinedChildren"));
        }
        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"));
        }
Ejemplo n.º 22
0
        public void Update()
        {
            int count = DataUtil.CountRows("IdentityKeys");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            IdentityKeyTestObject test1 = transaction1.Select(typeof(IdentityKeyTestObject), 2) as IdentityKeyTestObject;

            Assert.AreEqual(2, test1.Id);
            Assert.AreEqual("data2", test1.ObjData);

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

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

            ObjectTransaction transaction2 = manager.BeginTransaction();

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

            Assert.AreEqual(2, test2.Id);
            Assert.AreEqual("datatest", test2.ObjData);

            Assert.AreEqual(count, DataUtil.CountRows("IdentityKeys"));
        }
Ejemplo n.º 23
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"));
        }
Ejemplo n.º 24
0
        public void Update()
        {
            int  count = DataUtil.CountRows("GuidKeys");
            Guid id    = new Guid("{EEDD8FC4-9081-4573-B7E6-B3930FBDAA3C}");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            GuidKeyTestObject test1 = transaction1.Select(typeof(GuidKeyTestObject), id) as GuidKeyTestObject;

            Assert.AreEqual(id, test1.Id);
            Assert.AreEqual(2, test1.ObjData);

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

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

            ObjectTransaction transaction2 = manager.BeginTransaction();

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

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

            Assert.AreEqual(count, DataUtil.CountRows("GuidKeys"));
        }
Ejemplo n.º 25
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"));
        }
Ejemplo n.º 26
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"));
        }
Ejemplo n.º 27
0
        public void UpdateChild()
        {
            int parentCount   = DataUtil.CountRows("GuidParents");
            int childrenCount = DataUtil.CountRows("GuidChildren");

            ObjectTransaction transaction1 = manager.BeginTransaction();

            CascadeGuidChildTestObject child1 = transaction1.Select(typeof(CascadeGuidChildTestObject), "{0F455A52-C339-4A3C-9DCD-2620A5998295}") as CascadeGuidChildTestObject;

            Assert.AreEqual(new Guid("{0F455A52-C339-4A3C-9DCD-2620A5998295}"), child1.Id);
            Assert.AreEqual("1", child1.ObjData);
            Assert.AreEqual(new Guid("{C9ECFD97-F8BF-4075-A654-C62F6BD750D9}"), child1.Parent.Id);
            Assert.IsTrue(child1.Parent.ChildObjects.Contains(child1));

            child1.ObjData = "X";

            transaction1.Commit();

            Assert.AreEqual(parentCount, DataUtil.CountRows("GuidParents"));
            Assert.AreEqual(childrenCount, DataUtil.CountRows("GuidChildren"));

            ObjectTransaction transaction2 = manager.BeginTransaction();

            CascadeGuidChildTestObject child2 = transaction2.Select(typeof(CascadeGuidChildTestObject), "{0F455A52-C339-4A3C-9DCD-2620A5998295}") as CascadeGuidChildTestObject;

            Assert.AreEqual(new Guid("{0F455A52-C339-4A3C-9DCD-2620A5998295}"), child2.Id);
            Assert.AreEqual("X", child2.ObjData);
            Assert.AreEqual(new Guid("{C9ECFD97-F8BF-4075-A654-C62F6BD750D9}"), child2.Parent.Id);
            Assert.IsTrue(child2.Parent.ChildObjects.Contains(child2));

            Assert.AreEqual(parentCount, DataUtil.CountRows("GuidParents"));
            Assert.AreEqual(childrenCount, DataUtil.CountRows("GuidChildren"));
        }
Ejemplo n.º 28
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"));
        }
Ejemplo n.º 29
0
        public void InsertChildWithNoParent()
        {
            ObjectTransaction transaction = manager.BeginTransaction();

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

            child.ObjData = "test";

            transaction.Commit();
        }
Ejemplo n.º 30
0
        public void InsertChildWithNoParent()
        {
            ObjectTransaction transaction = manager.BeginTransaction();

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

            child.ObjData = "test";

            transaction.Commit();
        }