public void TestBoolean()
        {
            var db = new OrmTestSession();
            db.CreateTable<Vo>();

            for (int i = 0; i < 10; i++)
            {
                db.Insert(new Vo {Flag = (i%3 == 0), Text = String.Format("VO{0}", i)});
            }

            // count vo which flag is true            
            Assert.AreEqual(4, CountWithFlag(db, true));
            Assert.AreEqual(6, CountWithFlag(db, false));

            Debug.WriteLine("VO with true flag:");
            foreach (Vo vo in db.Query<Vo>("SELECT * FROM VO Where Flag = ?", true))
            {
                Debug.WriteLine(vo.ToString());
            }

            Debug.WriteLine("VO with false flag:");
            foreach (Vo vo in db.Query<Vo>("SELECT * FROM VO Where Flag = ?", false))
            {
                Debug.WriteLine(vo.ToString());
            }
        }
Exemple #2
0
        public void TestBoolean()
        {
            var db = new OrmTestSession();

            db.CreateTable <Vo>();

            for (int i = 0; i < 10; i++)
            {
                db.Insert(new Vo {
                    Flag = (i % 3 == 0), Text = String.Format("VO{0}", i)
                });
            }

            // count vo which flag is true
            Assert.AreEqual(4, CountWithFlag(db, true));
            Assert.AreEqual(6, CountWithFlag(db, false));

            Debug.WriteLine("VO with true flag:");
            foreach (Vo vo in db.Query <Vo>("SELECT * FROM VO Where Flag = ?", true))
            {
                Debug.WriteLine(vo.ToString());
            }

            Debug.WriteLine("VO with false flag:");
            foreach (Vo vo in db.Query <Vo>("SELECT * FROM VO Where Flag = ?", false))
            {
                Debug.WriteLine(vo.ToString());
            }
        }
Exemple #3
0
        public void InsertTwoTimes()
        {
            var db = new OrmTestSession();

            db.CreateTable <TestObj>();

            var obj1 = new TestObj {
                Text = "GLaDOS loves testing!"
            };
            var obj2 = new TestObj {
                Text = "Keep testing, just keep testing"
            };

            int numIn1 = db.Insert(obj1);
            int numIn2 = db.Insert(obj2);

            Assert.AreEqual(1, numIn1);
            Assert.AreEqual(1, numIn2);

            List <TestObj> result = db.Query <TestObj>("select * from TestObj").ToList();

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(obj1.Text, result[0].Text);
            Assert.AreEqual(obj2.Text, result[1].Text);

            db.Close();
        }
Exemple #4
0
        public void InsertIntoTwoTables()
        {
            var db = new OrmTestSession();

            db.CreateTable <TestObj>();
            db.CreateTable <TestObj2>();

            var obj1 = new TestObj {
                Text = "GLaDOS loves testing!"
            };
            var obj2 = new TestObj2 {
                Text = "Keep testing, just keep testing"
            };

            int numIn1 = db.Insert(obj1);

            Assert.AreEqual(1, numIn1);
            int numIn2 = db.Insert(obj2);

            Assert.AreEqual(1, numIn2);

            List <TestObj> result1 = db.Table <TestObj>().ToList();

            Assert.AreEqual(numIn1, result1.Count);
            Assert.AreEqual(obj1.Text, result1.First().Text);

            List <TestObj> result2 = db.Query <TestObj>("select * from TestObj2").ToList();

            Assert.AreEqual(numIn2, result2.Count);

            db.Close();
        }
Exemple #5
0
        public void InsertWithExtra()
        {
            var db = new OrmTestSession();

            db.CreateTable <TestObj2>();

            var obj1 = new TestObj2 {
                Id = 1, Text = "GLaDOS loves testing!"
            };
            var obj2 = new TestObj2 {
                Id = 1, Text = "Keep testing, just keep testing"
            };
            var obj3 = new TestObj2 {
                Id = 1, Text = "Done testing"
            };

            db.Insert(obj1);

            // "Expected unique constraint violation"
            ExceptionAssert.Throws <SqliteException>(() => db.Insert(obj2));

            db.Insert(obj2, ConflictResolution.Replace);

            // "Expected unique constraint violation"
            ExceptionAssert.Throws <SqliteException>(() => db.Insert(obj3));

            db.Insert(obj3, ConflictResolution.Ignore);

            List <TestObj> result = db.Query <TestObj>("select * from TestObj2").ToList();

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(obj2.Text, result.First().Text);

            db.Close();
        }
Exemple #6
0
        public void Unicode()
        {
            var insertItem = new TestObj {
                Text = "Sinéad O'Connor"
            };

            var db = new OrmTestSession();

            db.CreateTable <TestObj>();

            int numIn = db.Insert(insertItem);

            Assert.AreEqual(numIn, 1, "Num inserted must = num objects");

            TestObj inObjs = db.Query <TestObj>("select * from TestObj").First();

            Assert.AreEqual(insertItem.Text, inObjs.Text);
        }
        public void Unicode()
        {
            var insertItem = new TestObj { Text = "Sinéad O'Connor" };

            var db = new OrmTestSession();
            db.CreateTable<TestObj>();

            int numIn = db.Insert(insertItem);

            Assert.AreEqual(numIn, 1, "Num inserted must = num objects");

            TestObj inObjs = db.Query<TestObj>("select * from TestObj").First();

            Assert.AreEqual(insertItem.Text, inObjs.Text);
        }
        public void InsertWithExtra()
        {
            var db = new OrmTestSession();
            db.CreateTable<TestObj2>();

            var obj1 = new TestObj2 { Id = 1, Text = "GLaDOS loves testing!" };
            var obj2 = new TestObj2 { Id = 1, Text = "Keep testing, just keep testing" };
            var obj3 = new TestObj2 { Id = 1, Text = "Done testing" };

            db.Insert(obj1);

            // "Expected unique constraint violation"
            ExceptionAssert.Throws<SqliteException>(() => db.Insert(obj2));

            db.Insert(obj2, ConflictResolution.Replace);

            // "Expected unique constraint violation"
            ExceptionAssert.Throws<SqliteException>(() => db.Insert(obj3));

            db.Insert(obj3, ConflictResolution.Ignore);

            List<TestObj> result = db.Query<TestObj>("select * from TestObj2").ToList();
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(obj2.Text, result.First().Text);

            db.Close();
        }
        public void InsertTwoTimes()
        {
            var db = new OrmTestSession();
            db.CreateTable<TestObj>();

            var obj1 = new TestObj { Text = "GLaDOS loves testing!" };
            var obj2 = new TestObj { Text = "Keep testing, just keep testing" };

            int numIn1 = db.Insert(obj1);
            int numIn2 = db.Insert(obj2);
            Assert.AreEqual(1, numIn1);
            Assert.AreEqual(1, numIn2);

            List<TestObj> result = db.Query<TestObj>("select * from TestObj").ToList();
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(obj1.Text, result[0].Text);
            Assert.AreEqual(obj2.Text, result[1].Text);

            db.Close();
        }
        public void InsertIntoTwoTables()
        {
            var db = new OrmTestSession();
            db.CreateTable<TestObj>();
            db.CreateTable<TestObj2>();

            var obj1 = new TestObj { Text = "GLaDOS loves testing!" };
            var obj2 = new TestObj2 { Text = "Keep testing, just keep testing" };

            int numIn1 = db.Insert(obj1);
            Assert.AreEqual(1, numIn1);
            int numIn2 = db.Insert(obj2);
            Assert.AreEqual(1, numIn2);

            List<TestObj> result1 = db.Table<TestObj>().ToList();
            Assert.AreEqual(numIn1, result1.Count);
            Assert.AreEqual(obj1.Text, result1.First().Text);

            List<TestObj> result2 = db.Query<TestObj>("select * from TestObj2").ToList();
            Assert.AreEqual(numIn2, result2.Count);

            db.Close();
        }