private void ClearFilesAndIndex() { var files = _driver.Enum().ToArray(); foreach (var file in files.Where(x => _index.Get(new StorageItem { FileName = x }) == null)) { _driver.Remove(file); } foreach (var file in _index.Items.Where(x => !files.Contains(x.FileName)).ToArray()) { _index.Remove(file); } }
public void ReadFileNotExist() { _index.Get(Arg.Any <StorageItem>()).Returns(new StorageItem() { FileName = TestFileName }); _driver.Exists(Arg.Is(TestFileName)).Returns(true); _driver.Read(Arg.Any <string>()).Returns(x => Stream.Null); var storage = new XmlStorage(_driver, _index); Assert.DoesNotThrow(() => storage.Read <DataInfo>(TestFileName)); Assert.IsNull(storage.Read <DataInfo>(TestFileName)); _driver.Received(2).Read(Arg.Is(TestFileName)); }