示例#1
0
文件: BlobsTest.cs 项目: heruix/RTVS
        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);
            }
        }
示例#2
0
文件: BlobsTest.cs 项目: heruix/RTVS
        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]);
                }
            }
        }
示例#3
0
        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]);
                }
            }
        }
示例#4
0
        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);
            }
        }