Ejemplo n.º 1
0
        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>());
        }
Ejemplo n.º 2
0
        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
            });
        }
Ejemplo n.º 3
0
 public void Save()
 {
     XmlClassSerializer.Save(_items, _driver.Write(IndexName));
 }
 public Stream Write(string name)
 {
     return(_driver.Write(GetNameWithExtention(name)));
 }
 public void TestSetup()
 {
     _driver = Substitute.For <IStorageDriver>();
     _driver.Write(Arg.Is(XmlStorageIndex.IndexName)).Returns(ux => File.Create(XmlStorageIndex.IndexName));
 }