public void NewBinaryCanBeAddedAndTheDetailsRead() { var id = _cache.Add(new BinaryStorageClass(), _bytes); var details = _cache.Get(id); Assert.That(details.Id, Is.EqualTo(id)); }
public void BinariesCanBeUpdated() { var id = _cache.Add(new BinaryStorageClass(), _bytes); var details = _cache.Get(id); details.NameTag = 100; _cache.Update(details); _cache.Dispose(); _cache = new BinariesCache(_data); _cache.Open(_path); Assert.That(_cache.Get(id).NameTag, Is.EqualTo(100)); }
public void MissingDataIsRecoveredOnOpen() { var ids = Enumerable.Range(0, 20).Select(i => Guid.NewGuid()).ToList(); foreach (var guid in ids) { _cache.Add(new BinaryStorageClass { Id = guid }, _bytes); } //simulate a failure in which saving the data failed to commit (which could be caused by power failure, for example). _data.Data.Remove(_cache.Get(ids.Last()).FirstDataBlockId); //Reopen the file, which should discard the last binary, because it's data is missing _cache.Dispose(); _cache = new BinariesCache(_data); _cache.Open(_path); Assert.That(_cache.Get(ids.Last()), Is.Null); }
public void FileIndexIsRecoveredOnOpen() { var ids = Enumerable.Range(0, 20).Select(i => Guid.NewGuid()).ToList(); foreach (var guid in ids) { _cache.Add(new BinaryStorageClass { Id = guid }, _bytes); } _cache.Dispose(); _cache = new BinariesCache(_data); _cache.Open(_path); var newId = Guid.NewGuid(); _cache.Add(new BinaryStorageClass { Id = newId }, _bytes); Assert.That(_cache.Get(newId).FileIndex, Is.EqualTo(21)); }