public void WriteData() { var storage = new XmlStorage(_driver, _index); Assert.Throws <ArgumentNullException>(() => storage.Write <DataInfo>(null, "as")); Assert.Throws <ArgumentException>(() => storage.Write <DataInfo>(_info, "")); _driver.GetRandomName().Returns(TestFileName); _driver.Write(Arg.Any <string>()).Returns(x => new MemoryStream()); Assert.DoesNotThrow(() => storage.Write(_info, _info.Url)); _driver.Received(1).Write(Arg.Is(TestFileName)); _index.Received(1).Add(Arg.Any <StorageItem>()); }
public void Write <T>(T info, string url) where T : class { info.ThrowIfNull(nameof(info)); url.ThrowIfEmpty(nameof(url)); var name = _driver.GetRandomName(); BinarySerealizer.Save(info, _driver.Write(name)); _index.Add(new StorageItem { FileName = name, Url = url }); }