コード例 #1
0
        public void TestEmptyMigration()
        {
            var sqliteDbPath    = Path.Join(Environment.CurrentDirectory, $"{Guid.NewGuid()}.sqlite");
            var factory         = new CloudShopDalFactory();
            var dal             = factory.Create($"Data Source={sqliteDbPath}", DatabaseType.Sqlite);
            var migrationResult = dal.Migrate();

            migrationResult.IsSuccess.ShouldBeTrue();

            var users = dal.GetUsers();

            users.IsSuccess.ShouldBeTrue();
            users.Value.ShouldBeEmpty();
            var articles = dal.GetArticles();

            articles.IsSuccess.ShouldBeTrue();
            articles.Value.ShouldBeEmpty();
            var transactions = dal.GetTransactions();

            transactions.IsSuccess.ShouldBeTrue();
            transactions.Value.ShouldBeEmpty();

            File.Delete(sqliteDbPath);
            File.Exists(sqliteDbPath).ShouldBeFalse();
        }
コード例 #2
0
        public void CreateSampleDb()
        {
            var sqliteDbPath = GetSampleDbFile();

            if (File.Exists(sqliteDbPath))
            {
                File.Delete(sqliteDbPath);
            }
            File.Create(sqliteDbPath).Close();

            var factory         = new CloudShopDalFactory();
            var dal             = factory.Create($"Data Source={sqliteDbPath}", DatabaseType.Sqlite);
            var migrationResult = dal.Migrate();

            migrationResult.IsSuccess.ShouldBeTrue();
        }
コード例 #3
0
        public void TestMigrateSqlite()
        {
            var sqliteDbPath = Path.Join(Environment.CurrentDirectory, $"{Guid.NewGuid()}.sqlite");

            File.Exists(sqliteDbPath).ShouldBeFalse();
            File.Create(sqliteDbPath).Close();
            File.Exists(sqliteDbPath).ShouldBeTrue();

            var factory         = new CloudShopDalFactory();
            var dal             = factory.Create($"Data Source={sqliteDbPath}", DatabaseType.Sqlite);
            var migrationResult = dal.Migrate();

            migrationResult.IsSuccess.ShouldBeTrue();

            File.Delete(sqliteDbPath);
            File.Exists(sqliteDbPath).ShouldBeFalse();
        }