public async Task UploadsStreamInBlocksIfLengthNotAvailable()
        {
            TestStream        content  = new TestStream(_async, null, TestStream.Read(0, 10));
            TrackingArrayPool testPool = new TrackingArrayPool();
            StagingSink       sink     = new StagingSink();

            Mock <BlockBlobClient> clientMock = new Mock <BlockBlobClient>(MockBehavior.Strict, new Uri("http://mock"), new BlobClientOptions());

            clientMock.SetupGet(c => c.ClientConfiguration).CallBase();
            SetupInternalStaging(clientMock, sink);

            var uploader = new PartitionedUploader <BlobUploadOptions, BlobContentInfo>(BlockBlobClient.GetPartitionedUploaderBehaviors(clientMock.Object), default, arrayPool: testPool);
示例#2
0
        public async Task UploadsStreamInBlocksIfLengthNotAvailable()
        {
            TestStream        content  = new TestStream(_async, null, TestStream.Read(0, 10));
            TrackingArrayPool testPool = new TrackingArrayPool();
            StagingSink       sink     = new StagingSink();

            Mock <BlockBlobClient> clientMock = new Mock <BlockBlobClient>(MockBehavior.Strict, new Uri("http://mock"), new BlobClientOptions());

            clientMock.SetupGet(c => c.ClientDiagnostics).CallBase();
            SetupAsyncStaging(clientMock, sink);

            PartitionedUploader        uploader = new PartitionedUploader(clientMock.Object, default, arrayPool: testPool);
示例#3
0
        public async Task UploadsStreamInBlocksIfLengthNotAvailable()
        {
            TestStream        content  = new TestStream(_async, null, TestStream.Read(0, 10));
            TrackingArrayPool testPool = new TrackingArrayPool();
            AppendSink        sink     = new AppendSink();

            Mock <DataLakeFileClient> clientMock = new Mock <DataLakeFileClient>(
                MockBehavior.Strict,
                new Uri("http://mock"),
                new DataLakeClientOptions());

            clientMock.SetupGet(c => c.ClientConfiguration).CallBase();
            SetupInternalStaging(clientMock, sink);

            var uploader = new PartitionedUploader <DataLakeFileUploadOptions, PathInfo>(
                DataLakeFileClient.GetPartitionedUploaderBehaviors(clientMock.Object),
                transferOptions: default,
        public void Test_SpanOwnerOfT_AllocateFromCustomPoolAndGetMemoryAndSpan()
        {
            var pool = new TrackingArrayPool <int>();

            using (var buffer = SpanOwner <int> .Allocate(127, pool))
            {
                Assert.AreEqual(pool.RentedArrays.Count, 1);

                Assert.IsTrue(buffer.Length == 127);
                Assert.IsTrue(buffer.Span.Length == 127);

                buffer.Span.Fill(42);

                Assert.IsTrue(buffer.Span.ToArray().All(i => i == 42));
            }

            Assert.AreEqual(pool.RentedArrays.Count, 0);
        }
        public void Test_ArrayPoolBufferWriterOfT_AllocateFromCustomPoolAndGetMemoryAndSpan()
        {
            var pool = new TrackingArrayPool <byte>();

            using (var writer = new ArrayPoolBufferWriter <byte>(pool))
            {
                Assert.AreEqual(pool.RentedArrays.Count, 1);

                Assert.AreEqual(writer.Capacity, 256);
                Assert.AreEqual(writer.FreeCapacity, 256);
                Assert.AreEqual(writer.WrittenCount, 0);
                Assert.IsTrue(writer.WrittenMemory.IsEmpty);
                Assert.IsTrue(writer.WrittenSpan.IsEmpty);

                Span <byte> span = writer.GetSpan(43);

                Assert.IsTrue(span.Length >= 43);

                writer.Advance(43);

                Assert.AreEqual(writer.Capacity, 256);
                Assert.AreEqual(writer.FreeCapacity, 256 - 43);
                Assert.AreEqual(writer.WrittenCount, 43);
                Assert.AreEqual(writer.WrittenMemory.Length, 43);
                Assert.AreEqual(writer.WrittenSpan.Length, 43);

                Assert.ThrowsException <ArgumentOutOfRangeException>(() => writer.Advance(-1));
                Assert.ThrowsException <ArgumentOutOfRangeException>(() => writer.GetMemory(-1));
                Assert.ThrowsException <ArgumentException>(() => writer.Advance(1024));

                writer.Dispose();

                Assert.ThrowsException <ObjectDisposedException>(() => writer.WrittenMemory);
                Assert.ThrowsException <ObjectDisposedException>(() => writer.WrittenSpan.Length);
                Assert.ThrowsException <ObjectDisposedException>(() => writer.Capacity);
                Assert.ThrowsException <ObjectDisposedException>(() => writer.FreeCapacity);
                Assert.ThrowsException <ObjectDisposedException>(() => writer.Clear());
                Assert.ThrowsException <ObjectDisposedException>(() => writer.Advance(1));
            }

            Assert.AreEqual(pool.RentedArrays.Count, 0);
        }