public async Task CompressedBlob() { var createResult = await _session.EvaluateAsync("rtvs:::create_blob(raw(1000000))", REvaluationKind.Normal); createResult.Result.Should().NotBeNull(); var createCompressedResult = await _session.EvaluateAsync("rtvs:::create_compressed_blob(raw(1000000))", REvaluationKind.Normal); createCompressedResult.Result.Should().NotBeNull(); var blobId = ((JValue)createResult.Result).Value <ulong>(); var blobId2 = ((JValue)createCompressedResult.Result).Value <ulong>(); using (DataTransferSession dts = new DataTransferSession(_session, new FileSystem())) { var expectedData = await dts.FetchBytesAsync(new RBlobInfo(blobId), true, null, CancellationToken.None); var compressedData = await dts.FetchBytesAsync(new RBlobInfo(blobId2), true, null, CancellationToken.None); compressedData.Length.Should().BeLessThan(expectedData.Length); var actualData = await dts.FetchAndDecompressBytesAsync(new RBlobInfo(blobId2), true, null, CancellationToken.None); actualData.Should().Equal(expectedData); } }
public async Task CreateGetDestroyBlobs() { byte[] data1 = new byte[] { 0, 1, 2, 3, 4, 5 }; byte[] data2 = new byte[] { 10, 11, 12, 13, 14, 15 }; byte[] data3 = new byte[] { 20, 21, 22, 23, 24, 25 }; var dataSet = new byte[][] { data1, data2, data3 }; using (DataTransferSession dts = new DataTransferSession(_session, null)) { var blob1 = await dts.SendBytesAsync(data1, true, null, CancellationToken.None); var blob2 = await dts.SendBytesAsync(data2, true, null, CancellationToken.None); var blob3 = await dts.SendBytesAsync(data3, true, null, CancellationToken.None); blob1.Id.Should().BeGreaterThan(0); blob2.Id.Should().BeGreaterThan(0); blob3.Id.Should().BeGreaterThan(0); blob1.Id.Should().NotBe(blob2.Id); blob2.Id.Should().NotBe(blob3.Id); blob3.Id.Should().NotBe(blob1.Id); var blobIds = new IRBlobInfo[] { blob1, blob2, blob3 }; for (int i = 0; i < blobIds.Length; ++i) { var blob = await dts.FetchBytesAsync(blobIds[i], false, null, CancellationToken.None); blob.Should().Equal(dataSet[i]); } } }
public async Task CompressedZeroSizedBlob() { var createResult = await _session.EvaluateAsync("rtvs:::create_blob(raw())", REvaluationKind.Normal); createResult.Result.Should().NotBeNull(); var createCompressedResult = await _session.EvaluateAsync("rtvs:::create_compressed_blob(raw())", REvaluationKind.Normal); createCompressedResult.Result.Should().NotBeNull(); var blobId = ((JValue)createResult.Result).Value<ulong>(); var blobId2 = ((JValue)createCompressedResult.Result).Value<ulong>(); using (DataTransferSession dts = new DataTransferSession(_session, new FileSystem())) { var expectedData = await dts.FetchBytesAsync(new RBlobInfo(blobId), true, null, CancellationToken.None); var actualData = await dts.FetchAndDecompressBytesAsync(new RBlobInfo(blobId2), true, null, CancellationToken.None); actualData.Should().Equal(expectedData); } }