private static async Task <string> ExecuteRawSynchronizationRequest(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("destination"))); if (action != null) { action(); } await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("source"))); var sourceStream = new MemoryStream(); (await sourceClient.DownloadAsync("test")).CopyTo(sourceStream); var metadata = await sourceClient.GetMetadataForAsync("test"); var request = new SynchronizationMultipartRequest(destinationClient.Synchronization, new FileSystemInfo() { Url = sourceClient.UrlFor(), Id = sourceClient.GetServerIdAsync().Result }, "test", metadata, sourceStream, new[] { new RdcNeed() { BlockLength = 6, BlockType = RdcNeedType.Source, FileOffset = 0 } }); var synchronizationReport = await request.PushChangesAsync(CancellationToken.None); Assert.Null(synchronizationReport.Exception); var stream = await destinationClient.DownloadAsync("test"); return(StreamToString(stream)); }
private static async Task<string> ExecuteRawSynchronizationRequest(IAsyncFilesCommands sourceClient, IAsyncFilesCommands destinationClient, Action action = null) { await destinationClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("destination"))); if (action != null) action(); await sourceClient.UploadAsync("test", new MemoryStream(Encoding.UTF8.GetBytes("source"))); var sourceStream = new MemoryStream(); (await sourceClient.DownloadAsync("test")).CopyTo(sourceStream); var metadata = await sourceClient.GetMetadataForAsync("test"); var request = new SynchronizationMultipartRequest(destinationClient.Synchronization, new ServerInfo() { FileSystemUrl = sourceClient.UrlFor(), Id = sourceClient.GetServerIdAsync().Result }, "test", metadata, sourceStream, new[] { new RdcNeed() { BlockLength = 6, BlockType = RdcNeedType.Source, FileOffset = 0 } }); var synchronizationReport = await request.PushChangesAsync(CancellationToken.None); Assert.Null(synchronizationReport.Exception); var stream = await destinationClient.DownloadAsync("test"); return StreamToString(stream); }