public GivenARollingBlobWriterOnExistingBlobs()
        {
            _storageAccount = TestUtilities.GetStorageAccount();
            _containerName  = "testesistingblobs" + Guid.NewGuid().ToString("N").ToLowerInvariant();

            GetContainer().Create();

            var existingBlobWriter =
                new RollingBlobWriter(
                    Mock.Of <IBlobNamingStrategy>(ns => ns.GetNamePrefix() == Prefix),
                    Mock.Of <IColdStorageInstrumentationPublisher>(),
                    _storageAccount,
                    _containerName,
                    rollSizeMb: 1,
                    blocksAllowed: BlocksAllowed,
                    blockSize: BlockSize);

            // setup first blob
            existingBlobWriter.WriteAsync(
                new[]
            {
                TestUtilities.CreateBlockData(new string('z', 1024 * 1024), BlockSize),
            },
                CancellationToken.None).Wait();

            // setup a payload of 1023KB for second blob
            _existingBlobContents = new string('z', 1024 * 1024 - 1024);

            // setup second blob
            existingBlobWriter.WriteAsync(
                new[]
            {
                TestUtilities.CreateBlockData(_existingBlobContents, BlockSize),
            },
                CancellationToken.None).Wait();

            _sut =
                new RollingBlobWriter(
                    Mock.Of <IBlobNamingStrategy>(ns => ns.GetNamePrefix() == Prefix),
                    Mock.Of <IColdStorageInstrumentationPublisher>(),
                    _storageAccount,
                    _containerName,
                    rollSizeMb: 1,
                    blocksAllowed: BlocksAllowed,
                    blockSize: BlockSize);
        }
        public async Task WhenWritingSingleBlock_ThenBlockIsAppendedToLastBlob()
        {
            var payloadString = new string('a', 50);

            await _sut.WriteAsync(
                new[]
            {
                TestUtilities.CreateBlockData(payloadString, BlockSize)
            },
                CancellationToken.None);

            Assert.Equal(
                _existingBlobContents + payloadString,
                await GetContainer()
                .GetBlockBlobReference(Prefix + "1")
                .DownloadTextAsync(Encoding.UTF8, AccessCondition.GenerateEmptyCondition(), null, null));
        }
        public GivenARollingBlobWriterOnExistingBlobs()
        {
            _storageAccount = TestUtilities.GetStorageAccount();
            _containerName = "testesistingblobs" + Guid.NewGuid().ToString("N").ToLowerInvariant();

            GetContainer().Create();

            var existingBlobWriter =
                new RollingBlobWriter(
                    Mock.Of<IBlobNamingStrategy>(ns => ns.GetNamePrefix() == Prefix),
                    Mock.Of<IColdStorageInstrumentationPublisher>(),
                    _storageAccount,
                    _containerName,
                    rollSizeMb: 1,
                    blocksAllowed: BlocksAllowed,
                    blockSize: BlockSize);

            // setup first blob
            existingBlobWriter.WriteAsync(
                new[] 
                {
                    TestUtilities.CreateBlockData(new string('z', 1024*1024), BlockSize),
                },
                CancellationToken.None).Wait();

            // setup a payload of 1023KB for second blob
            _existingBlobContents = new string('z', 1024 * 1024 - 1024);

            // setup second blob
            existingBlobWriter.WriteAsync(
                new[] 
                {
                    TestUtilities.CreateBlockData(_existingBlobContents, BlockSize),
                },
                CancellationToken.None).Wait();

            _sut =
                new RollingBlobWriter(
                    Mock.Of<IBlobNamingStrategy>(ns => ns.GetNamePrefix() == Prefix),
                    Mock.Of<IColdStorageInstrumentationPublisher>(),
                    _storageAccount,
                    _containerName,
                    rollSizeMb: 1,
                    blocksAllowed: BlocksAllowed,
                    blockSize: BlockSize);
        }