Ejemplo n.º 1
0
        public async Task Test2_SqlServer_SqlServer()
        {
            using (var localDb = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test2_Local"))
                using (var remoteDb = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test2_Remote"))
                {
                    await localDb.Database.EnsureDeletedAsync();

                    await remoteDb.Database.EnsureDeletedAsync();

                    await localDb.Database.MigrateAsync();

                    await remoteDb.Database.MigrateAsync();

                    var remoteConfigurationBuilder =
                        new SqlSyncConfigurationBuilder(remoteDb.ConnectionString)
                        .Table("Users")
                        .Table("Posts")
                        .Table("Comments");

                    var remoteSyncProvider = new SqlSyncProvider(remoteConfigurationBuilder.Configuration);

                    var localConfigurationBuilder =
                        new SqlSyncConfigurationBuilder(localDb.ConnectionString)
                        .Table("Users")
                        .Table("Posts")
                        .Table("Comments");

                    var localSyncProvider = new SqlSyncProvider(localConfigurationBuilder.Configuration);

                    await Test2(localDb,
                                localSyncProvider,
                                remoteDb,
                                remoteSyncProvider);
                }
        }
        public async Task Test_SqlServer_SqlServer_DeleteWithForeignKeys()
        {
            using var localDb  = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test_Sqlite_Sqlite_DeleteWithForeignKeys_local");
            using var remoteDb = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test_Sqlite_Sqlite_DeleteWithForeignKeys_remote");
            await localDb.Database.EnsureDeletedAsync();

            await remoteDb.Database.EnsureDeletedAsync();

            await localDb.Database.MigrateAsync();

            await remoteDb.Database.MigrateAsync();

            var remoteConfigurationBuilder =
                new SqlSyncConfigurationBuilder(remoteDb.ConnectionString)
                .Table("Users")
                .Table("Posts")
                .Table("Comments");

            var remoteSyncProvider = new SqlSyncProvider(remoteConfigurationBuilder.Build(), ProviderMode.Remote, logger: new ConsoleLogger("REM"));

            var localConfigurationBuilder =
                new SqlSyncConfigurationBuilder(localDb.ConnectionString)
                .Table("Users")
                .Table("Posts")
                .Table("Comments");

            var localSyncProvider = new SqlSyncProvider(localConfigurationBuilder.Build(), ProviderMode.Local, logger: new ConsoleLogger("LOC"));


            await TestSyncAgentDeleteWithForeignKeys(localDb, localSyncProvider, remoteDb, remoteSyncProvider);
        }
        public async Task Test1_SqlServer_Sqlite()
        {
            var remoteDbFile = $"{Path.GetTempPath()}Test1_SqlServer_Sqlite_remote.sqlite";

            if (File.Exists(remoteDbFile))
            {
                File.Delete(remoteDbFile);
            }

            using var localDb  = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test1_Local");
            using var remoteDb = new SqliteBlogDbContext($"Data Source={remoteDbFile}");
            await localDb.Database.EnsureDeletedAsync();

            await remoteDb.Database.EnsureDeletedAsync();

            await localDb.Database.MigrateAsync();

            await remoteDb.Database.MigrateAsync();

            var remoteConfigurationBuilder =
                new SqliteSyncConfigurationBuilder(remoteDb.ConnectionString)
                .Table <User>("Users")
                .Table <Post>("Posts")
                .Table <Comment>("Comments");

            var remoteSyncProvider = new SqliteSyncProvider(remoteConfigurationBuilder.Build(), logger: new ConsoleLogger("REM"));
            await remoteSyncProvider.ApplyProvisionAsync();

            var localConfigurationBuilder =
                new SqlSyncConfigurationBuilder(localDb.ConnectionString)
                .Table("Users")
                .Table("Posts")
                .Table("Comments");


            var localSyncProvider = new SqlSyncProvider(localConfigurationBuilder.Build(), logger: new ConsoleLogger("LOC"));
            await localSyncProvider.ApplyProvisionAsync();


            await Test1(localDb, localSyncProvider, remoteDb, remoteSyncProvider);
        }
Ejemplo n.º 4
0
        public async Task TestSyncAgent_Sqlite_SqlServer()
        {
            var localDbFile = $"{Path.GetTempPath()}TestSyncAgent_Sqlite_SqlServer_local.sqlite";

            if (File.Exists(localDbFile))
            {
                File.Delete(localDbFile);
            }

            using (var localDb = new SqliteBlogDbContext($"Data Source={localDbFile}"))
                using (var remoteDb = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=TestSyncAgent_Sqlite_SqlServer_Remote"))
                {
                    await localDb.Database.EnsureDeletedAsync();

                    await remoteDb.Database.EnsureDeletedAsync();

                    await localDb.Database.MigrateAsync();

                    await remoteDb.Database.MigrateAsync();

                    var remoteConfigurationBuilder =
                        new SqlSyncConfigurationBuilder(remoteDb.ConnectionString)
                        .Table("Users")
                        .Table("Posts")
                        .Table("Comments");

                    var remoteSyncProvider = new SqlSyncProvider(remoteConfigurationBuilder.Configuration);

                    var localConfigurationBuilder =
                        new SqliteSyncConfigurationBuilder(localDb.ConnectionString)
                        .Table <User>("Users")
                        .Table <Post>("Posts")
                        .Table <Comment>("Comments");

                    var localSyncProvider = new SqliteSyncProvider(localConfigurationBuilder.Configuration);


                    await TestSyncAgent(localDb, localSyncProvider, remoteDb, remoteSyncProvider);
                }
        }
        public async Task Test1_SqlServer_SqlServer()
        {
            using var localDb  = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test1_Local");
            using var remoteDb = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test1_Remote");
            await localDb.Database.EnsureDeletedAsync();

            await remoteDb.Database.EnsureDeletedAsync();

            await localDb.Database.MigrateAsync();

            await remoteDb.Database.MigrateAsync();

            var remoteConfigurationBuilder =
                new SqlSyncConfigurationBuilder(remoteDb.ConnectionString)
                .Table("Users")
                .Table("Posts")
                .Table("Comments");

            var remoteSyncProvider = new SqlSyncProvider(remoteConfigurationBuilder.Build(), logger: new ConsoleLogger("REM"));
            await remoteSyncProvider.ApplyProvisionAsync();

            var localConfigurationBuilder =
                new SqlSyncConfigurationBuilder(localDb.ConnectionString)
                .Table("Users")
                .Table("Posts")
                .Table("Comments");

            var localSyncProvider = new SqlSyncProvider(localConfigurationBuilder.Build(), logger: new ConsoleLogger("LOC"));
            await localSyncProvider.ApplyProvisionAsync();


            await Test1(localDb,
                        localSyncProvider,
                        remoteDb,
                        remoteSyncProvider);
        }