コード例 #1
0
ファイル: IntegrationTests.cs プロジェクト: miseeger/LimeBean
        public void ImplicitTransactionsOnStoreAndTrash()
        {
            using (var conn = SQLitePortability.CreateConnection()) {
                conn.Open();

                IDatabaseDetails details = new SQLiteDetails();
                IDatabaseAccess  db      = new DatabaseAccess(conn, details);
                IKeyAccess       keys    = new KeyUtil();
                DatabaseStorage  storage = new DatabaseStorage(details, db, keys);
                IBeanFactory     factory = new BeanFactory();
                IBeanCrud        crud    = new BeanCrud(storage, db, keys, factory);

                storage.EnterFluidMode();

                var bean = crud.Dispense <ThrowingBean>();
                bean["foo"] = "ok";
                var id = crud.Store(bean);

                bean.Throw  = true;
                bean["foo"] = "fail";

                try { crud.Store(bean); } catch { }
                Assert.Equal("ok", db.Cell <string>(true, "select foo from test where id = {0}", id));

                try { crud.Trash(bean); } catch { }
                Assert.True(db.Cell <int>(true, "select count(*) from test") > 0);
            }
        }
コード例 #2
0
        public DatabaseAccessTests()
        {
            _conn = SQLitePortability.CreateConnection();
            _conn.Open();

            _db = new DatabaseAccess(_conn, new SQLiteDetails());
        }
コード例 #3
0
        public DirtyTrackingTests()
        {
            _api = SQLitePortability.CreateApi();
            _api.Exec("create table foo(id, a, b)");
            _api.Exec("insert into foo values(1, 'initial', 'initial')");

            _bean = _api.Load("foo", 1);

            _api.QueryExecuting += cmd => _queryCount++;
        }
コード例 #4
0
        public DatabaseStorageTests_SQLite()
        {
            _conn = SQLitePortability.CreateConnection();
            _conn.Open();

            IDatabaseDetails details = new SQLiteDetails();

            _db      = new DatabaseAccess(_conn, details);
            _keys    = new KeyUtil();
            _storage = new DatabaseStorage(details, _db, _keys);
        }
コード例 #5
0
ファイル: IntegrationTests.cs プロジェクト: miseeger/LimeBean
        public void DisableImplicitTransactions()
        {
            using (var api = SQLitePortability.CreateApi()) {
                api.EnterFluidMode();
                api.ImplicitTransactions = false;

                var bean = api.Dispense <ThrowingBean>();
                bean.Throw = true;
                try { api.Store(bean); } catch { }

                Assert.Equal(1, api.Count <ThrowingBean>());
            }
        }
コード例 #6
0
ファイル: IntegrationTests.cs プロジェクト: miseeger/LimeBean
        public void Api_DetailsSelection()
        {
            Assert.Equal("SQLite", new BeanApi(SQLitePortability.CreateConnection()).CreateDetails().DbName);

#if !NO_MSSQL
            Assert.Equal("MsSql", new BeanApi(new System.Data.SqlClient.SqlConnection()).CreateDetails().DbName);
#endif

#if !NO_MARIADB
            Assert.Equal("MariaDB", new BeanApi(new MySql.Data.MySqlClient.MySqlConnection()).CreateDetails().DbName);
#endif

#if !NO_PGSQL
            Assert.Equal("PgSql", new BeanApi(new Npgsql.NpgsqlConnection()).CreateDetails().DbName);
#endif
        }
コード例 #7
0
ファイル: IntegrationTests.cs プロジェクト: miseeger/LimeBean
        public void Regression_NullingExistingProp()
        {
            using (var api = SQLitePortability.CreateApi()) {
                api.EnterFluidMode();

                var bean = api.Dispense("kind1");
                bean["p"] = 123;

                var id = api.Store(bean);

                bean["p"] = null;
                api.Store(bean);

                bean = api.Load("kind1", id);
                Assert.Null(bean["p"]);
            }
        }
コード例 #8
0
ファイル: IntegrationTests.cs プロジェクト: miseeger/LimeBean
        public void ApiLink()
        {
            using (var api = SQLitePortability.CreateApi()) {
                api.EnterFluidMode();

                var bean = api.Dispense <ApiLinkChecker>();
                var id   = api.Store(bean);
                Assert.Same(api, bean.Trace["bs"]);
                Assert.Same(api, bean.Trace["as"]);

                bean = api.Load <ApiLinkChecker>(id);
                Assert.Same(api, bean.Trace["bl"]);
                Assert.Same(api, bean.Trace["al"]);

                api.Trash(bean);
                Assert.Same(api, bean.Trace["bt"]);
                Assert.Same(api, bean.Trace["at"]);
            }
        }
コード例 #9
0
        public DatabaseBeanFinderTests()
        {
            _conn = SQLitePortability.CreateConnection();
            _conn.Open();

            IDatabaseDetails details = new SQLiteDetails();
            IDatabaseAccess  db      = new DatabaseAccess(_conn, details);
            IKeyAccess       keys    = new KeyUtil();
            IStorage         storage = new DatabaseStorage(details, db, keys);
            IBeanCrud        crud    = new BeanCrud(storage, db, keys);
            IBeanFinder      finder  = new DatabaseBeanFinder(details, db, crud);

            db.Exec("create table foo(x)");
            db.Exec("insert into foo(x) values(1)");
            db.Exec("insert into foo(x) values(2)");
            db.Exec("insert into foo(x) values(3)");

            _db     = db;
            _finder = finder;
        }
コード例 #10
0
 public CustomKeysTests()
 {
     _api = SQLitePortability.CreateApi();
 }