Beispiel #1
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 };

            var blob1 = await _session.CreateBlobAsync(data1);

            var blob2 = await _session.CreateBlobAsync(data2);

            var blob3 = await _session.CreateBlobAsync(data3);

            blob1.Should().BeGreaterThan(0);
            blob2.Should().BeGreaterThan(0);
            blob3.Should().BeGreaterThan(0);

            blob1.Should().NotBe(blob2);
            blob2.Should().NotBe(blob3);
            blob3.Should().NotBe(blob1);
            var blobIds = new ulong[] { blob1, blob2, blob3 };

            for (int i = 0; i < blobIds.Length; ++i)
            {
                var blob = await _session.GetBlobAsync(blobIds[i]);

                blob.Should().Equal(dataSet[i]);
            }

            await _session.DestroyBlobsAsync(blobIds);
        }
Beispiel #2
0
        public async Task ZeroSizedBlob()
        {
            byte[] data   = new byte[] { };
            var    blobId = await _session.CreateBlobAsync();

            blobId.Should().BeGreaterThan(0);

            var res = await _session.BlobReadAllAsync(blobId);

            res.Should().Equal(new byte[0]);

            await _session.DestroyBlobsAsync(new[] { blobId });
        }
Beispiel #3
0
        /// <summary>
        /// Sends file to R-Host as a blob. This method adds the blob for clean up by default.
        /// </summary>
        /// <param name="filePath">Path to the file to be sent to R-Host.</param>
        /// <param name="doCleanUp">true to add blob created upon transfer for cleanup on dispose, false to ignore it after transfer.</param>
        public async Task <IRBlobInfo> SendFileAsync(string filePath, bool doCleanUp = true)
        {
            byte[] bytes  = _fs.FileReadAllBytes(filePath);
            ulong  blobId = await _session.CreateBlobAsync(bytes);

            var result = new Blob(blobId, bytes);

            if (doCleanUp)
            {
                _cleanup.Add(result);
            }
            return(result);
        }