예제 #1
0
        public void ByteArrays()
        {
            //Byte Arrays for comparisson
            ByteArrayClass[] byteArrays = new ByteArrayClass[] {
                new ByteArrayClass()
                {
                    bytes = new byte[] { 1, 2, 3, 4, 250, 252, 253, 254, 255 }
                },                                                                                                   //Range check
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0 }
                },                                                                 //null bytes need to be handled correctly
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0, 0 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0, 1, 0 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { 1, 0, 1 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { }
                },                                                               //Empty byte array should stay empty (and not become null)
                new ByteArrayClass()
                {
                    bytes = null
                }                                                     //Null should be supported
            };

            SQLiteConnection database = new SQLiteConnection(TestPath.GetTempFileName());

            database.CreateTable <ByteArrayClass>();

            //Insert all of the ByteArrayClass
            foreach (ByteArrayClass b in byteArrays)
            {
                database.Insert(b);
            }

            //Get them back out
            ByteArrayClass[] fetchedByteArrays = database.Table <ByteArrayClass>().OrderBy(x => x.ID).ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, byteArrays.Length);
            //Check they are the same
            for (int i = 0; i < byteArrays.Length; i++)
            {
                byteArrays[i].AssertEquals(fetchedByteArrays[i]);
            }
        }
예제 #2
0
        public void NullableEnum()
        {
            SQLiteConnection db = new SQLiteConnection(TestPath.GetTempFileName());

            db.CreateTable <NullableEnumClass> ();

            var withNull = new NullableEnumClass {
                NullableIntEnum = null, NullableTextEnum = null
            };
            var with1 = new NullableEnumClass {
                NullableIntEnum = TestIntEnum.One, NullableTextEnum = null
            };
            var with2 = new NullableEnumClass {
                NullableIntEnum = TestIntEnum.Two, NullableTextEnum = null
            };
            var withNullA = new NullableEnumClass {
                NullableIntEnum = null, NullableTextEnum = TestTextEnum.Alpha
            };
            var with1B = new NullableEnumClass {
                NullableIntEnum = TestIntEnum.One, NullableTextEnum = TestTextEnum.Beta
            };

            db.Insert(withNull);
            db.Insert(with1);
            db.Insert(with2);
            db.Insert(withNullA);
            db.Insert(with1B);

            var results = db.Table <NullableEnumClass> ().OrderBy(x => x.ID).ToArray();

            Assert.AreEqual(5, results.Length);

            Assert.AreEqual(withNull, results[0]);
            Assert.AreEqual(with1, results[1]);
            Assert.AreEqual(with2, results[2]);
            Assert.AreEqual(withNullA, results[3]);
            Assert.AreEqual(with1B, results[4]);
        }
예제 #3
0
        public void NullableInt()
        {
            SQLiteConnection db = new SQLiteConnection(TestPath.GetTempFileName());

            db.CreateTable <NullableIntClass>();

            NullableIntClass withNull = new NullableIntClass()
            {
                NullableInt = null
            };
            NullableIntClass with0 = new NullableIntClass()
            {
                NullableInt = 0
            };
            NullableIntClass with1 = new NullableIntClass()
            {
                NullableInt = 1
            };
            NullableIntClass withMinus1 = new NullableIntClass()
            {
                NullableInt = -1
            };

            db.Insert(withNull);
            db.Insert(with0);
            db.Insert(with1);
            db.Insert(withMinus1);

            NullableIntClass[] results = db.Table <NullableIntClass>().OrderBy(x => x.ID).ToArray();

            Assert.AreEqual(4, results.Length);

            Assert.AreEqual(withNull, results[0]);
            Assert.AreEqual(with0, results[1]);
            Assert.AreEqual(with1, results[2]);
            Assert.AreEqual(withMinus1, results[3]);
        }
예제 #4
0
 public TestDb() : base(TestPath.GetTempFileName())
 {
     Trace = true;
 }
예제 #5
0
 public void Setup()
 {
     _db = new TestDb(TestPath.GetTempFileName());
 }
예제 #6
0
 public void Setup()
 {
     _db = new TestDb(TestPath.GetTempFileName(), new DefalutConvert());
 }
예제 #7
0
 public TestDb(bool storeDateTimeAsTicks = true, object key = null) : base(TestPath.GetTempFileName(), storeDateTimeAsTicks, key: key)
 {
     Trace = true;
 }