示例#1
0
        public void SelectCellTest <T>(T pExpectedValue, string sqlSelectStatement)
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            Assert.AreEqual(pExpectedValue, sqlite.SelectCell <T>(sqlSelectStatement));
        }
示例#2
0
        public void SelectCell_WrongUsing3()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, true));
            sqlite.SelectCell <bool>("SELECT f1,f2 FROM WrongTable;");
        }
示例#3
0
        public void PutFileWrongUsage()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            Assert.IsFalse(sqlite.PutFile(Environment.CurrentDirectory + "\\TestDataStorage\\test_image_picture-128.png", "insert into test (f1, f4) values (@f1);",
                                          new SQLiteParameter("@f1", "file_test")));
        }
示例#4
0
        public void PutFileNotExists()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            Assert.IsFalse(sqlite.PutFile(Environment.CurrentDirectory + "\\TestDataStorage\\not_exists_file.png", "insert into test (f1, f4) values (@f1, @file);",
                                          new SQLiteParameter("@f1", "file_test")));
        }
示例#5
0
        public void SelectRow_WrongUsing()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            Assert.IsNull(sqlite.SelectRow("SELECT f1 FROM WrongTable;"));
            Assert.IsNull(sqlite.SelectRow("SELECT f1 FROM TestTable UNION ALL SELECT f1 FROM TestTable;"));
        }
示例#6
0
        public void SelectRow()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            Assert.IsNotNull(sqlite.SelectRow("SELECT f1 FROM TestTable;"));
            Assert.IsNotNull(sqlite.SelectRow("SELECT * FROM TestTable;", 0));
        }
示例#7
0
        public void SelectCell_DefaultReturnValues()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            Assert.AreEqual(true, Convert.ToBoolean(sqlite.SelectCell <Int64>("SELECT f2 FROM TestTable;", 0)));
            Assert.AreEqual(true, sqlite.SelectCell <bool>("SELECT f999 FROM TestTable;", true));
        }
示例#8
0
        public void SelectTable_SelectTableUsingArguments()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            Assert.AreEqual("text1", sqlite.SelectTable("SELECT f1 FROM TestTable WHERE f1=@param;", new SQLiteParameter("@param", "text1")).Rows[0].ItemArray[0]);
            Assert.IsNullOrEmpty(sqlite.LastOperationErrorMessage);
        }
示例#9
0
        public void SelectCell_DataTypes1()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, true));
            Assert.AreEqual(DBNull.Value, sqlite.SelectCell <DBNull>("SELECT f4 FROM TestTable;"));
            Assert.AreEqual(DateTime.Now.ToString("dd.MM.yyyy"), Convert.ToDateTime(sqlite.SelectCell <string>("SELECT date('now');")).ToString("dd.MM.yyyy"));
        }
示例#10
0
        public void SelectTable_SelectWholeTable()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            Assert.IsNotNull(sqlite.SelectTable("SELECT * FROM TestTable;"));
            Assert.IsNullOrEmpty(sqlite.LastOperationErrorMessage);
        }
示例#11
0
        public void TestConnection_ConnectionStringIsNotDefined2()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsFalse(sqlite.TestConnection("", true));
            Assert.IsNotNullOrEmpty(sqlite.LastOperationErrorMessage);
            Assert.IsFalse(sqlite.IsConnectionIsActive);
        }
示例#12
0
        public void GetImage()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            Image image = sqlite.GetImage("select f4 from test where f1 = 'file_test' limit 1;");

            Assert.IsNotNull(image);
        }
示例#13
0
        public void TestConnection_CanBeEstablished2()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, true));
            Assert.That(connectionString, Is.EqualTo(sqlite.ConnectionString));
            Assert.IsFalse(sqlite.IsConnectionIsActive);
            sqlite.Disconnect();
            Assert.IsFalse(sqlite.IsConnectionIsActive);
        }
示例#14
0
        public void ChangeData_CreateTable()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            if (sqlite.SelectTable("SELECT * FROM test;") != null)
            {
                sqlite.ChangeData(sqlDropTestTable);
            }
            Assert.GreaterOrEqual(0, sqlite.ChangeData(sqlTestTableStatement));
            Assert.IsNullOrEmpty(sqlite.LastOperationErrorMessage);
        }
示例#15
0
        public void PerformTransaction()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString, true, false));
            Assert.AreEqual(
                sqlite.PerformTransaction(new SQLiteQueryStatement[] {
                new SQLiteQueryStatement()
                {
                    QuerySql        = "insert into test (f1) values (@v);",
                    QueryParameters = new SQLiteParameter[] {
                        new SQLiteParameter("@v", "transaction_test_1")
                    }
                },
                new SQLiteQueryStatement()
                {
                    QuerySql        = "insert into test (f1) values (@v);",
                    QueryParameters = new SQLiteParameter[] {
                        new SQLiteParameter("@v", "transaction_test_1")
                    }
                }
            }), 2);
        }
示例#16
0
        public void TestConnection_CanBeEstablished1()
        {
            SQLite3Query sqlite = new SQLite3Query();

            Assert.IsTrue(sqlite.TestConnection(connectionString));
        }