Esempio n. 1
0
 public void Setup()
 {
     var cache = new FilesystemCache(CACHE_NAME);
     cache.Clear();
     _sut = new BlockStore(cache, 3);
 }
Esempio n. 2
0
        private void Real_files(IKeyValueStore cache)
        {
            var start = DateTime.Now;

            _sut = new BlockStore(cache);

            var results = new List<BlockUploadSummary>();
            _sut.On_blocks_stored += _ =>
            {
                results.Add(_);
                Console.WriteLine("stored: {0} bytes to {1} - {2}", _.TotalNumberOfBytes, _.BlockGroupId, DateTime.Now.Subtract(start));
            };

            using (var fs = new FileStream(@"files\doc.pdf", FileMode.Open)) { _sut.Store_blocks(fs); }
            using (var fs = new FileStream(@"files\music.mp3", FileMode.Open)) { _sut.Store_blocks(fs); }

            using (var fs = new FileStream(@"docrestored.pdf", FileMode.Create))
            {
                _sut.Load_blocks(results[0].BlockGroupId, fs);
                Assert.AreEqual(new FileInfo(@"files\doc.pdf").Length, new FileInfo("docrestored.pdf").Length);
                Console.WriteLine("doc restored - {0}", DateTime.Now.Subtract(start));
            }
            using (var fs = new FileStream(@"musicrestored.mp3", FileMode.Create))
            {
                _sut.Load_blocks(results[1].BlockGroupId, fs);
                Assert.AreEqual(new FileInfo(@"files\music.mp3").Length, new FileInfo("musicrestored.mp3").Length);
                Console.WriteLine("music restored - {0}", DateTime.Now.Subtract(start));
            }
        }