public void Summarize_blocks()
        {
            var summary = new BlockUploadSummary { BlockGroupId = Guid.NewGuid(), BlockSize = 3 };
            BlockUploadSummary result = null;

            summary.Aggregate(new Tuple<byte[], int>(new byte[] { 1, 2, 3 }, 0), null);
            summary.Aggregate(new Tuple<byte[], int>(new byte[] { 4, 5 }, 1), null);
            summary.Aggregate(new Tuple<byte[], int>(null, 2), _ => result = _);

            Assert.AreSame(summary, result);
            Assert.AreEqual(summary.BlockGroupId, result.BlockGroupId);
            Assert.AreEqual(5, result.TotalNumberOfBytes);
            Assert.AreEqual(3, result.BlockSize);
            Assert.AreEqual(2, result.NumberOfBlocks);
        }
Пример #2
0
 public void Store_blocks(Stream source)
 {
     var blockGroupId = Guid.NewGuid();
     var summary = new BlockUploadSummary {BlockGroupId = blockGroupId, BlockSize =  _blockSize};
     _groupOps.Stream_blocks(source, block0 =>
             Store_block(blockGroupId, block0, block1 =>
                 summary.Aggregate(block1, _ =>
                 {
                     _headOps.Write_number_of_blocks(_.BlockGroupId, _.NumberOfBlocks);
                     On_blocks_stored(_);
                 })));
 }