Exemplo n.º 1
0
        private SQLiteConnection CreateDb()
        {
            var db = new TestDb();

            db.CreateTable<TestTable>();
            db.CreateTable<TestTableCompositeKey>();

            var items =
                from i in Enumerable.Range(0, Count)
                select new TestTable
                {
                    Datum = 1000 + i,
                    Test = "Hello World"
                }
                ;
            db.InsertAll(items);

            var itemsCompositeKey =
                from i in Enumerable.Range(0, Count)
                select new TestTableCompositeKey
                {
                    Datum = 1000 + i,
                    Test = "Hello World",
                    Id = i,
                    TestIndex = i + 1
                }
                ;
            db.InsertAll(itemsCompositeKey);
            Assert.AreEqual(Count, db.Table<TestTableCompositeKey>().Count());

            return db;
        }
Exemplo n.º 2
0
 private TestDb CreateDb()
 {
     var db = new TestDb();
     db.CreateTable<Product>();
     db.CreateTable<Order>();
     db.CreateTable<OrderLine>();
     db.CreateTable<OrderHistory>();
     return db;
 }
Exemplo n.º 3
0
        public void CreateAsPassedInTypes()
        {
            var db = new TestDb();

            db.CreateTable(typeof (Product));
            db.CreateTable(typeof (Order));
            db.CreateTable(typeof (OrderLine));
            db.CreateTable(typeof (OrderHistory));

            VerifyCreations(db);
        }
Exemplo n.º 4
0
        public void CreateThem()
        {
            var db = new TestDb();

            db.CreateTable<Product>();
            db.CreateTable<Order>();
            db.CreateTable<OrderLine>();
            db.CreateTable<OrderHistory>();

            VerifyCreations(db);
        }
Exemplo n.º 5
0
        public void SetUp()
        {
            _db = new TestDb();
            _db.CreateTable<Product>();
            _db.CreateTable<Order>();
            _db.CreateTable<OrderLine>();

            var p1 = new Product
            {
                Name = "One",
            };
            var p2 = new Product
            {
                Name = "Two",
            };
            var p3 = new Product
            {
                Name = "Three",
            };
            _db.InsertAll(new[] {p1, p2, p3});

            var o1 = new Order
            {
                PlacedTime = DateTime.Now,
            };
            var o2 = new Order
            {
                PlacedTime = DateTime.Now,
            };
            _db.InsertAll(new[] {o1, o2});

            _db.InsertAll(new[]
            {
                new OrderLine
                {
                    OrderId = o1.Id,
                    ProductId = p1.Id,
                    Quantity = 1,
                },
                new OrderLine
                {
                    OrderId = o1.Id,
                    ProductId = p2.Id,
                    Quantity = 2,
                },
                new OrderLine
                {
                    OrderId = o2.Id,
                    ProductId = p3.Id,
                    Quantity = 3,
                }
            });
        }
Exemplo n.º 6
0
        public void UpperAndLowerColumnNames()
        {
            using (var db = new TestDb(true)
            {
                TraceListener = DebugTraceListener.Instance
            })
            {
                db.CreateTable<LowerId>();
                db.CreateTable<UpperId>();

                List<SQLiteConnection.ColumnInfo> cols = db.GetTableInfo("Test").ToList();
                Assert.That(cols.Count, Is.EqualTo(1));
                Assert.That(cols[0].Name, Is.EqualTo("Id"));
            }
        }
Exemplo n.º 7
0
        public void TestColumnValues()
        {
            using (TestDb db = new TestDb())
            {
                db.CreateTable<WithDefaultValue>();
               

                string failed = string.Empty;
                foreach (var col in db.GetMapping<WithDefaultValue>().Columns)
                {
                    if (col.PropertyName == "TestInt" && !col.DefaultValue.Equals(WithDefaultValue.IntVal))
                        failed += " , TestInt does not equal " + WithDefaultValue.IntVal;

                    if (col.PropertyName == "TestDecimal" && !col.DefaultValue.Equals(WithDefaultValue.DecimalVal))
                        failed += "TestDecimal does not equal " + WithDefaultValue.DecimalVal;

                    if (col.PropertyName == "TestDateTime" && !col.DefaultValue.Equals(WithDefaultValue.DateTimegVal))
                        failed += "TestDateTime does not equal " + WithDefaultValue.DateTimegVal;

                    if (col.PropertyName == "TestString" && !col.DefaultValue.Equals(WithDefaultValue.StringVal))
                        failed += "TestString does not equal " + WithDefaultValue.StringVal;
                }
                
                Assert.True(string.IsNullOrWhiteSpace(failed), failed);

            }
        }
        public void ImplicitIndex()
        {
            var db = new TestDb();

            db.CreateTable<NoAttributes>(CreateFlags.ImplicitIndex);

            TableMapping mapping = db.GetMapping<NoAttributes>();
            TableMapping.Column column = mapping.Columns[2];
            Assert.AreEqual("IndexedId", column.Name);
            Assert.IsTrue(column.Indices.Any());
        }
Exemplo n.º 9
0
 public void CreateUniqueIndexes()
 {
     using (var db = new TestDb())
     {
         db.CreateTable<TheOne>();
         List<IndexInfo> indexes = db.Query<IndexInfo>("PRAGMA INDEX_LIST (\"TheOne\")");
         Assert.AreEqual(4, indexes.Count, "# of indexes");
         CheckIndex(db, indexes, "UX_Uno", true, "Uno");
         CheckIndex(db, indexes, "UX_Dos", true, "Dos", "Tres");
         CheckIndex(db, indexes, "UX_Uno_bool", true, "Cuatro");
         CheckIndex(db, indexes, "UX_Dos_bool", true, "Cinco", "Seis");
     }
 }
        public void ImplicitAutoIncAsPassedInTypes()
        {
            var db = new TestDb();

            db.CreateTable(typeof (PkAttribute), CreateFlags.AutoIncPK);

            TableMapping mapping = db.GetMapping<PkAttribute>();

            Assert.IsNotNull(mapping.PK);
            Assert.AreEqual("Id", mapping.PK.Name);
            Assert.IsTrue(mapping.PK.IsPK);
            Assert.IsTrue(mapping.PK.IsAutoInc);
        }
Exemplo n.º 11
0
 private SQLiteConnection CreateDb()
 {
     var db = new TestDb();
     db.CreateTable<TestTable>();
     IEnumerable<TestTable> items = from i in Enumerable.Range(0, Count)
         select new TestTable
         {
             Two = 2
         };
     db.InsertAll(items);
     Assert.AreEqual(Count, db.Table<TestTable>().Count());
     return db;
 }
Exemplo n.º 12
0
        public void HasGoodNames()
        {
            var db = new TestDb();

            db.CreateTable<AFunnyTableName>();

            TableMapping mapping = db.GetMapping<AFunnyTableName>();

            Assert.AreEqual("AGoodTableName", mapping.TableName);

            Assert.AreEqual("Id", mapping.Columns[0].Name);
            Assert.AreEqual("AGoodColumnName", mapping.Columns[1].Name);
        }
        public void ImplicitAutoInc()
        {
            var db = new TestDb();

            db.CreateTable<PkAttribute>(CreateFlags.AutoIncPK);

            TableMapping mapping = db.GetMapping<PkAttribute>();

            Assert.IsFalse(mapping.HasCompositePK);
            Assert.IsNotNull(mapping.PK);
            Assert.AreEqual("Id", mapping.PK.Name);
            Assert.IsTrue(mapping.PK.IsPK);
            Assert.IsTrue(mapping.PK.IsAutoInc);
        }
Exemplo n.º 14
0
        public void CanUseSubtypeOfTableAttribute()
        {
            var db = new TestDb();
            db.CreateTable<Cat>();

            db.Insert(new Cat()
            {
                Breed = "Siamese"
            });

            int numCats = db.ExecuteScalar<int>("select count(*) from Cats");

            Assert.That(numCats,Is.EqualTo(1), "The resulting num cats should be 1.");
        }
Exemplo n.º 15
0
        public void ToUpper()
        {
            var db = new TestDb();

            db.CreateTable<TestTable>();
            var testTable = new TestTable()
            {
                Name = "test"
            };
            db.Insert(testTable);

            var x = db.Table<TestTable>().Where(t => t.Name.ToUpper() == "TEST");

            Assert.AreEqual(1, x.Count());
        }
        void TestDateTimeOffset (TestDb db)
        {
            db.CreateTable<TestObj> ();

            TestObj o, o2;

            //
            // Ticks
            //
            o = new TestObj {
                ModifiedTime = new DateTimeOffset (2012, 1, 14, 3, 2, 1, TimeSpan.Zero),
            };
            db.Insert (o);
            o2 = db.Get<TestObj> (o.Id);
            Assert.AreEqual (o.ModifiedTime, o2.ModifiedTime);
        }
Exemplo n.º 17
0
        public void CreateTableWithNotNullConstraints()
        {
            using (var db = new TestDb())
            {
                db.CreateTable<NotNullNoPK>();
                var cols = db.GetTableInfo("NotNullNoPK");

                var joined = from expected in GetExpectedColumnInfos(db.Platform.ReflectionService, typeof(NotNullNoPK))
                             join actual in cols on expected.Name equals actual.Name
                             where actual.notnull != expected.notnull
                             select actual.Name;

                Assert.AreNotEqual(0, cols.Count(), "Failed to get table info");
                Assert.IsTrue(joined.Count() == 0, string.Format("not null constraint was not created for the following properties: {0}"
                    , string.Join(", ", joined.ToArray())));
            }
        }
Exemplo n.º 18
0
        public void Insert()
        {
            var db = new TestDb();

            db.CreateTable <Product>();

            string testString = "\u2329\u221E\u232A";

            db.Insert(new Product
            {
                Name = testString,
            });

            var p = db.Get <Product>(1);

            Assert.AreEqual(testString, p.Name);
        }
Exemplo n.º 19
0
		public void Insert()
		{
			var db = new TestDb();

			db.CreateTable<UnicodeProduct>();

			string testString = "\u2329\u221E\u232A";

			db.Insert(new UnicodeProduct
			{
				Name = testString,
			});

			var p = db.Get<UnicodeProduct>(1);

			Assert.AreEqual(testString, p.Name);
		}
Exemplo n.º 20
0
        private void TestDateTime(TestDb db)
        {
            db.CreateTable <TestObj>();

            TestObj o, o2;

            //
            // Ticks
            //
            o = new TestObj
            {
                ModifiedTime = new DateTime(2012, 1, 14, 3, 2, 1),
            };
            db.Insert(o);
            o2 = db.Get <TestObj>(o.Id);
            Assert.AreEqual(o.ModifiedTime, o2.ModifiedTime);
        }
Exemplo n.º 21
0
        public void TestColumnValues()
        {
            using (TestDb db = new TestDb())
            {
                db.CreateTable <WithDefaultValue>();


                string failed = string.Empty;
                foreach (var col in db.GetMapping <WithDefaultValue>().Columns)
                {
                    if (col.PropertyName == "TestInt" && !col.DefaultValue.Equals(WithDefaultValue.IntVal))
                    {
                        failed += " , TestInt does not equal " + WithDefaultValue.IntVal;
                    }


                    if (col.PropertyName == "TestDecimal" && !col.DefaultValue.Equals(WithDefaultValue.DecimalVal))
                    {
                        failed += "TestDecimal does not equal " + WithDefaultValue.DecimalVal;
                    }

                    if (col.PropertyName == "TestDateTime" && !col.DefaultValue.Equals(WithDefaultValue.DateTimegVal))
                    {
                        failed += "TestDateTime does not equal " + WithDefaultValue.DateTimegVal;
                    }

                    if (col.PropertyName == "TestString" && !col.DefaultValue.Equals(WithDefaultValue.StringVal))
                    {
                        failed += "TestString does not equal " + WithDefaultValue.StringVal;
                    }

                    if (col.PropertyName == "DefaultValueInAttributeTestInt" && !col.DefaultValue.Equals(WithDefaultValue.IntVal))
                    {
                        failed += " , DefaultValueInAttributeTestInt does not equal " + WithDefaultValue.IntVal;
                    }

                    if (col.PropertyName == "TestIntWithSubtypeOfDefault" && !col.DefaultValue.Equals(WithDefaultValue.IntVal))
                    {
                        failed += " , TestIntWithSubtypeOfDefault does not equal " + WithDefaultValue.IntVal;
                    }
                }

                Assert.True(string.IsNullOrWhiteSpace(failed), failed);
            }
        }
Exemplo n.º 22
0
        private SQLiteConnection CreateDb()
        {
            var db = new TestDb();

            db.CreateTable <TestTable>();
            var items =
                from i in Enumerable.Range(0, Count)
                select new TestTable
            {
                Datum = 1000 + i,
                Test  = "Hello World"
            }
            ;

            db.InsertAll(items);
            Assert.AreEqual(Count, db.Table <TestTable>().Count());
            return(db);
        }
Exemplo n.º 23
0
		public void Query()
		{
			var db = new TestDb();

			db.CreateTable<UnicodeProduct>();

			string testString = "\u2329\u221E\u232A";

			db.Insert(new UnicodeProduct
			{
				Name = testString,
			});

			var ps = (from p in db.Table<UnicodeProduct>() where p.Name == testString select p).ToList();

			Assert.AreEqual(1, ps.Count);
			Assert.AreEqual(testString, ps[0].Name);
		}
Exemplo n.º 24
0
        public void Query()
        {
            var db = new TestDb();

            db.CreateTable <Product>();

            string testString = "\u2329\u221E\u232A";

            db.Insert(new Product
            {
                Name = testString,
            });

            List <Product> ps = (from p in db.Table <Product>() where p.Name == testString select p).ToList();

            Assert.AreEqual(1, ps.Count);
            Assert.AreEqual(testString, ps[0].Name);
        }
Exemplo n.º 25
0
        public void Issue115_MissingPrimaryKey()
        {
            using (var conn = new TestDb())
            {
                conn.CreateTable<Issue115_MyObject>();
                conn.InsertAll(from i in Enumerable.Range(0, 10)
                    select new Issue115_MyObject
                    {
                        UniqueId = i.ToString(),
                        OtherValue = (byte) (i*10),
                    });

                TableQuery<Issue115_MyObject> query = conn.Table<Issue115_MyObject>();
                foreach (Issue115_MyObject itm in query)
                {
                    itm.OtherValue++;
                    Assert.AreEqual(1, conn.Update(itm, typeof (Issue115_MyObject)));
                }
            }
        }
Exemplo n.º 26
0
        private void TestDateTime(TestDb db)
        {
            db.CreateTable<TestObj>();

            //
            // Ticks
            //
            var org = new TestObj
            {
                Time1 = DateTime.UtcNow,
                Time2 = DateTime.Now,
            };
            db.Insert(org);
            var fromDb = db.Get<TestObj>(org.Id);
            Assert.AreEqual(fromDb.Time1.ToUniversalTime(), org.Time1.ToUniversalTime());
            Assert.AreEqual(fromDb.Time2.ToUniversalTime(), org.Time2.ToUniversalTime());

            Assert.AreEqual(fromDb.Time1.ToLocalTime(), org.Time1.ToLocalTime());
            Assert.AreEqual(fromDb.Time2.ToLocalTime(), org.Time2.ToLocalTime());
        }
Exemplo n.º 27
0
        private void TestDateTime(TestDb db)
        {
            db.CreateTable<TestObj>();

            TestObj o, o2;

            //
            // Ticks
            //
            o = new TestObj
            {
                ModifiedTime = DateTime.UtcNow,
            };
            db.Insert(o);
            o2 = db.Get<TestObj>(o.Id);
            Assert.AreEqual(o.ModifiedTime, o2.ModifiedTime.ToUniversalTime());

            var expectedTimeZone = db.StoreDateTimeAsTicks ? DateTimeKind.Utc : DateTimeKind.Local;
            Assert.AreEqual(o2.ModifiedTime.Kind, expectedTimeZone);
        }
Exemplo n.º 28
0
        public void CreateInsertDrop()
        {
            var db = new TestDb();

            db.CreateTable <Product>();

            db.Insert(new Product
            {
                Name  = "Hello",
                Price = 16,
            });

            int n = db.Table <Product>().Count();

            Assert.AreEqual(1, n);

            db.DropTable <Product>();

            ExceptionAssert.Throws <SQLiteException>(() => db.Table <Product>().Count());
        }
Exemplo n.º 29
0
        public void Issue115_MissingPrimaryKey()
        {
            using (var conn = new TestDb())
            {
                conn.CreateTable <Issue115_MyObject>();
                conn.InsertAll(from i in Enumerable.Range(0, 10)
                               select new Issue115_MyObject
                {
                    UniqueId   = i.ToString(),
                    OtherValue = (byte)(i * 10),
                });

                TableQuery <Issue115_MyObject> query = conn.Table <Issue115_MyObject>();
                foreach (Issue115_MyObject itm in query)
                {
                    itm.OtherValue++;
                    Assert.AreEqual(1, conn.Update(itm, typeof(Issue115_MyObject)));
                }
            }
        }
Exemplo n.º 30
0
        public void CreateInsertDrop()
        {
            var db = new TestDb();

            db.CreateTable<Product>();

            db.Insert(new Product
            {
                Name = "Hello",
                Price = 16,
            });

            int n = db.Table<Product>().Count();

            Assert.AreEqual(1, n);

            db.DropTable<Product>();

            ExceptionAssert.Throws<SQLiteException>(() => db.Table<Product>().Count());
        }
Exemplo n.º 31
0
        private void TestDateTime(TestDb db)
        {
            db.CreateTable <TestObj>();

            TestObj o, o2;

            //
            // Ticks
            //
            o = new TestObj
            {
                ModifiedTime = DateTime.UtcNow,
            };
            db.Insert(o);
            o2 = db.Get <TestObj>(o.Id);
            Assert.AreEqual(o.ModifiedTime, o2.ModifiedTime.ToUniversalTime());

            var expectedTimeZone = db.StoreDateTimeAsTicks ? DateTimeKind.Utc : DateTimeKind.Local;

            Assert.AreEqual(o2.ModifiedTime.Kind, expectedTimeZone);
        }
Exemplo n.º 32
0
        private void TestDateTime(TestDb db)
        {
            db.CreateTable <TestObj>();

            //
            // Ticks
            //
            var org = new TestObj
            {
                Time1 = DateTime.UtcNow,
                Time2 = DateTime.Now,
            };

            db.Insert(org);
            var fromDb = db.Get <TestObj>(org.Id);

            Assert.AreEqual(fromDb.Time1.ToUniversalTime(), org.Time1.ToUniversalTime());
            Assert.AreEqual(fromDb.Time2.ToUniversalTime(), org.Time2.ToUniversalTime());

            Assert.AreEqual(fromDb.Time1.ToLocalTime(), org.Time1.ToLocalTime());
            Assert.AreEqual(fromDb.Time2.ToLocalTime(), org.Time2.ToLocalTime());
        }
Exemplo n.º 33
0
        public void Issue86()
        {
            var db = new TestDb();
            db.CreateTable<Foo>();

            db.Insert(new Foo
            {
                Bar = 42
            });
            db.Insert(new Foo
            {
                Bar = 69
            });

            Foo found42 = db.Table<Foo>().Where(f => f.Bar == 42).FirstOrDefault();
            Assert.IsNotNull(found42);

            var ordered = new List<Foo>(db.Table<Foo>().OrderByDescending(f => f.Bar));
            Assert.AreEqual(2, ordered.Count);
            Assert.AreEqual(69, ordered[0].Bar);
            Assert.AreEqual(42, ordered[1].Bar);
        }
Exemplo n.º 34
0
        public void ExecuteNonQueryWithNullThrowsException()
        {
            using (TestDb db = new TestDb())
            {
                TableMapping map;

                db.CreateTable <NotNullNoPK>();

                try
                {
                    NotNullNoPK obj = new NotNullNoPK()
                    {
                        AnotherRequiredStringProp = "Another required prop",
                        RequiredIntProp           = 123,
                        RequiredStringProp        = "Required string prop"
                    };
                    db.Insert(obj);

                    map = db.GetMapping <NotNullNoPK>();
                    map.GetInsertCommand(db, "OR REPLACE").ExecuteNonQuery(new object[] { 1, null, 123, null, null, null });
                }
                catch (NotNullConstraintViolationException)
                {
                    return;
                }
                catch (SQLiteException ex)
                {
                    if (db.Platform.SQLiteApi.LibVersionNumber() < 3007017 && ex.Result == Result.Constraint)
                    {
                        Assert.Inconclusive("Detailed constraint information is only available in SQLite3 version 3.7.17 and above.");
                    }
                }
                catch (Exception ex)
                {
                    Assert.Fail("Expected an exception of type NotNullConstraintViolationException to be thrown. An exception of type {0} was thrown instead.", ex.GetType().Name);
                }
            }
            Assert.Fail("Expected an exception of type NotNullConstraintViolationException to be thrown. No exception was thrown.");
        }
Exemplo n.º 35
0
        public void SetUp()
        {
            db = new TestDb();
            db.CreateTable <Product>();

            var prods = new[]
            {
                new Product
                {
                    Name = "Foo"
                },
                new Product
                {
                    Name = "Bar"
                },
                new Product
                {
                    Name = "Foobar"
                }
            };

            db.InsertAll(prods);
        }
Exemplo n.º 36
0
        public void SetUp()
        {
            db = new TestDb();
            db.CreateTable<Product>();

            var prods = new[]
            {
                new Product
                {
                    Name = "Foo"
                },
                new Product
                {
                    Name = "Bar"
                },
                new Product
                {
                    Name = "Foobar"
                }
            };

            db.InsertAll(prods);
        }
Exemplo n.º 37
0
        public void Issue303_WhereNot_A()
        {
            using (var db = new TestDb())
            {
                db.CreateTable <Issue303_A>();
                db.Insert(new Issue303_A {
                    Id = 1, Name = "aa"
                });
                db.Insert(new Issue303_A {
                    Id = 2, Name = null
                });
                db.Insert(new Issue303_A {
                    Id = 3, Name = "test"
                });
                db.Insert(new Issue303_A {
                    Id = 4, Name = null
                });

                var r = (from p in db.Table <Issue303_A>() where !(p.Name == null) select p).ToList();
                Assert.AreEqual(2, r.Count);
                Assert.AreEqual(1, r[0].Id);
                Assert.AreEqual(3, r[1].Id);
            }
        }
Exemplo n.º 38
0
        public void Issue303_WhereNot_B()
        {
            using (var db = new TestDb())
            {
                db.CreateTable <Issue303_B>();
                db.Insert(new Issue303_B {
                    Id = 1, Flag = true
                });
                db.Insert(new Issue303_B {
                    Id = 2, Flag = false
                });
                db.Insert(new Issue303_B {
                    Id = 3, Flag = true
                });
                db.Insert(new Issue303_B {
                    Id = 4, Flag = false
                });

                var r = (from p in db.Table <Issue303_B>() where !p.Flag select p).ToList();
                Assert.AreEqual(2, r.Count);
                Assert.AreEqual(2, r[0].Id);
                Assert.AreEqual(4, r[1].Id);
            }
        }
Exemplo n.º 39
0
 public void SetUp()
 {
     _db = new TestDb();
     _db.CreateTable <ComplexType>();
 }
Exemplo n.º 40
0
        public void NullableSumTest()
        {
            SQLiteConnection db = new TestDb();
            db.CreateTable<NullableIntClass>();

            var r = db.ExecuteScalar<int>("SELECT SUM(NullableInt) FROM NullableIntClass WHERE 1 = 0");

            Assert.AreEqual(0, r);
        }
        public void UpdateQueryWithNullThrowsException()
        {
            // Skip this test if the Dll doesn't support the extended SQLITE_CONSTRAINT codes
            using (TestDb db = new TestDb())
            {

                db.CreateTable<NotNullNoPK>();

                try
                {
                    db.Execute("insert into \"NotNullNoPK\" (AnotherRequiredStringProp, RequiredIntProp, RequiredStringProp) values(?, ?, ?)",
                        new object[] { "Another required string", 123, "Required string" });

                    db.Execute("update \"NotNullNoPK\" set AnotherRequiredStringProp=?, RequiredIntProp=?, RequiredStringProp=? where ObjectId=?",
                        new object[] { "Another required string", 123, null, 1 });
                }
                catch (NotNullConstraintViolationException)
                {
                    return;
                }
                catch (SQLiteException ex)
                {
                    if (db.Platform.SQLiteApi.LibVersionNumber() < 3007017 && ex.Result == Result.Constraint)
                    {
                        Assert.Inconclusive("Detailed constraint information is only available in SQLite3 version 3.7.17 and above.");
                    }
                }
                catch (Exception ex)
                {
                    Assert.Fail("Expected an exception of type NotNullConstraintViolationException to be thrown. An exception of type {0} was thrown instead.", ex.GetType().Name);
                }
                Assert.Fail("Expected an exception of type NotNullConstraintViolationException to be thrown. No exception was thrown.");
            }
        }
        public void NotNullConstraintExceptionListsOffendingColumnsOnUpdate()
        {
            using (TestDb db = new TestDb())
            {
                // Skip this test if the Dll doesn't support the extended SQLITE_CONSTRAINT codes
                if (db.Platform.SQLiteApi.LibVersionNumber() >= 3007017)
                {
                    db.CreateTable<NotNullNoPK>();

                    try
                    {
                        NotNullNoPK obj = new NotNullNoPK()
                        {
                            AnotherRequiredStringProp = "Another required string",
                            RequiredIntProp = 123,
                            RequiredStringProp = "Required string"
                        };
                        db.Insert(obj);
                        obj.RequiredStringProp = null;
                        db.Update(obj);
                    }
                    catch (NotNullConstraintViolationException ex)
                    {
                        string expected = "RequiredStringProp";
                        string actual = string.Join(", ", ex.Columns.Where(c => !c.IsPK).OrderBy(p => p.PropertyName).Select(c => c.PropertyName));

                        Assert.AreEqual(expected, actual, "NotNullConstraintViolationException did not correctly list the columns that violated the constraint");

                        return;
                    }
                    catch (SQLiteException ex)
                    {
                        if (db.Platform.SQLiteApi.LibVersionNumber() < 3007017 && ex.Result == Result.Constraint)
                        {
                            Assert.Inconclusive("Detailed constraint information is only available in SQLite3 version 3.7.17 and above.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Assert.Fail(
                            "Expected an exception of type NotNullConstraintViolationException to be thrown. An exception of type {0} was thrown instead.",
                            ex.GetType().Name);
                    }
                    Assert.Fail("Expected an exception of type NotNullConstraintViolationException to be thrown. No exception was thrown.");
                }
            }
        }
        public void NotNullConstraintExceptionListsOffendingColumnsOnInsert()
        {
            using (TestDb db = new TestDb())
            {

                db.CreateTable<NotNullNoPK>();

                try
                {
                    NotNullNoPK obj = new NotNullNoPK() { RequiredStringProp = "Some value" };
                    db.Insert(obj);
                }
                catch (NotNullConstraintViolationException ex)
                {
                    string expected = "AnotherRequiredStringProp, RequiredIntProp";
                    string actual = string.Join(", ", ex.Columns.Where(c => !c.IsPK).OrderBy(p => p.PropertyName).Select(c => c.PropertyName));

                    Assert.AreEqual(expected, actual, "NotNullConstraintViolationException did not correctly list the columns that violated the constraint");
                    return;
                }
                catch (SQLiteException ex)
                {
                    if (db.Platform.SQLiteApi.LibVersionNumber() < 3007017 && ex.Result == Result.Constraint)
                    {
                        Assert.Inconclusive("Detailed constraint information is only available in SQLite3 version 3.7.17 and above.");
                    }
                }
                Assert.Fail("Expected an exception of type NotNullConstraintViolationException to be thrown. No exception was thrown.");
            }
        }
        public void UpdateWithNullThrowsException()
        {
            using (TestDb db = new TestDb())
            {

                db.CreateTable<NotNullNoPK>();

                try
                {
                    NotNullNoPK obj = new NotNullNoPK()
                    {
                        AnotherRequiredStringProp = "Another required string",
                        RequiredIntProp = 123,
                        RequiredStringProp = "Required string"
                    };
                    db.Insert(obj);
                    obj.RequiredStringProp = null;
                    db.Update(obj);
                }
                catch (NotNullConstraintViolationException)
                {
                    return;
                }
                catch (SQLiteException ex)
                {
                    if (db.Platform.SQLiteApi.LibVersionNumber() < 3007017 && ex.Result == Result.Constraint)
                    {
                        Assert.Inconclusive("Detailed constraint information is only available in SQLite3 version 3.7.17 and above.");
                    }
                }
            }
            Assert.Fail("Expected an exception of type NotNullConstraintViolationException to be thrown. No exception was thrown.");
        }