public void GetTableSQLTest()
        {
            using (var ds = new SQLiteDatastore())
            {
                ds.CreateTable("something", new ColumnInfo[] { new ColumnInfo("data") });

                var tableSQL = ds.GetTableSQL("something");
                tableSQL.Should().NotBeNullOrWhiteSpace();
                Output.WriteLine(tableSQL);
            }
        }
        public void GetRowCountTest()
        {
            using (var ds = new SQLiteDatastore())
            {
                ds.CreateTable("something", new ColumnInfo[] { new ColumnInfo("data") });

                var rowCnt = ds.GetRowCount("something", null);
                Assert.True(rowCnt == 0);

                ds.Execute("INSERT INTO something DEFAULT VALUES");

                rowCnt = ds.GetRowCount("something", null);
                Assert.Equal(1, rowCnt);
            }
        }
        public void ReadOnly_Throws_On_BeginTransaction()
        {
            var path = _testReadOnlyPath;

            Output.WriteLine(path);

            using (var ds = new SQLiteDatastore(path))
            {
                ds.Execute(TestDBBuilder.CREATE_AUTOINCREMENT_TABLE);
                ds.CreateTable("Tbl", new ColumnInfo[] { new ColumnInfo()
                                                         {
                                                             Name = "Data", DBType = System.Data.DbType.String
                                                         } }, false);

                System.IO.File.Exists(path).Should().BeTrue();
                System.IO.File.SetAttributes(path, System.IO.FileAttributes.ReadOnly);

                ds.Invoking(x => x.BeginTransaction()).Should().Throw <ReadOnlyException>();
            }
        }
        public void CreateTableTest()
        {
            using (var ds = new SQLiteDatastore())
            {
                var cols = new ColumnInfo[]
                {
                    new ColumnInfo("ID", System.Data.DbType.Int64)
                    {
                        AutoIncrement = true
                    },
                    new ColumnInfo("Field1", System.Data.DbType.AnsiString)
                };

                ds.CreateTable("TableA", cols, false);

                ds.Invoking(x => x.Execute("EXPLAIN SELECT * FROM TableA;")).Should().NotThrow();

                ds.CheckTableExists("TableA").Should().BeTrue();
            }
        }
        public void ReadOnly_Throws_On_Insert()
        {
            var path = _testReadOnlyPath;

            Output.WriteLine(path);

            using (var ds = new SQLiteDatastore(path))
            {
                ds.Execute(TestDBBuilder.CREATE_AUTOINCREMENT_TABLE);
                ds.CreateTable("Tbl", new ColumnInfo[] { new ColumnInfo()
                                                         {
                                                             Name = "Data", DBType = System.Data.DbType.String
                                                         } }, false);

                System.IO.File.Exists(path).Should().BeTrue();
                System.IO.File.SetAttributes(path, System.IO.FileAttributes.ReadOnly);

                //TODO assert that connection is not open and transaction depth is 0
                ds.Invoking(x => x.Execute("INSERT INTO Tbl (Data) VALUES ('something');")).Should().Throw <ReadOnlyException>();
            }
        }