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();
        }
        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();
        }