public void NestedTransactionTest_FullCommit()
        {
            using (var ds = new SQLiteDatastore())
            {
                ds.CurrentTransaction.Should().BeNull();
                ds.TransactionDepth.Should().Be(0);

                ds.Execute("CREATE TABLE TableA (Data TEXT);");

                ds.BeginTransaction();

                ds.CurrentTransaction.Should().NotBeNull();
                ds.TransactionDepth.Should().Be(1);

                ds.BeginTransaction();

                ds.CurrentTransaction.Should().NotBeNull();
                ds.TransactionDepth.Should().Be(2);

                ds.Execute("INSERT INTO TableA VALUES ('something');");

                ds.CommitTransaction();
                ds.GetRowCount("TableA", null).Should().Be(1);

                ds.CurrentTransaction.Should().NotBeNull();
                ds.TransactionDepth.Should().Be(1);

                ds.CommitTransaction();
                ds.GetRowCount("TableA", null).Should().Be(1);

                ds.CurrentTransaction.Should().BeNull();
                ds.TransactionDepth.Should().Be(0);
            }
        }
        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 FluentInterfaceTest_With_Many()
        {
            int recordsToCreate = 1000;

            using (var ds = new SQLiteDatastore())
            {
                ds.Execute(TestDBBuilder.CREATE_MULTIPROPTABLE);
                ds.BeginTransaction();
                for (int i = 1; i <= recordsToCreate; i++)
                {
                    ds.Execute(string.Format(" INSERT INTO MultiPropTable (IntField, NIntField) VALUES ({0}, {0});\r\n", i));
                }
                ds.CommitTransaction();

                Assert.Equal(recordsToCreate, ds.GetRowCount("MultiPropTable", null));

                StartTimer();
                var result = ds.From <POCOMultiTypeObject>().Limit(5000, 0).Query();
                EndTimer();

                result.Should().NotBeEmpty();
                result.Should().HaveCount(recordsToCreate);

                foreach (DOMultiPropType item in
                         ds.From <DOMultiPropType>().Read())
                {
                    item.FloatField = 1.0F;
                    ds.Update(item);
                }
            }
        }
        protected void VerifySQLiteDatastore(SQLiteDatastore ds)
        {
            ds.Should().NotBeNull();
            ds.Exists.Should().BeTrue();

            ds.Invoking(x => x.Execute("EXPLAIN SELECT 1;")).Should().NotThrow();

            ds.GetRowCount("sqlite_master", null, null).Should().BeGreaterThan(0);
        }
예제 #5
0
        public void VerifySQLiteDatastore(SQLiteDatastore ds)
        {
            Assert.True(ds.Exists, "Assert file exists");
            AssertEx.NotNullOrWhitespace(ds.Extension, "Assert file has extension");

            Assert.NotNull(ds);
            AssertEx.NotNullOrWhitespace(ds.Path);

            var explaneSelectResult = ds.Execute("EXPLAIN SELECT 1;");
            Assert.NotNull(explaneSelectResult);
            Assert.True(ds.GetRowCount("sqlite_master", null, null) > 0);
        }