public void RemovesXmlFromOriginIfEmpty() { var mem = new ConcurrentDictionary <string, byte[]>(); var contents = new CachedXmlContents(new RamContents(mem)); contents.Xml("a/b/c.xml", () => new XDocument(new XElement("first", "read"))); contents.UpdateXml("a/b/c.xml", new XDocument()); Assert.False( mem.ContainsKey("a/b/c.xml") ); }
public void UpdatesXmlInCache() { var mem = new CachedXmlContents(new RamContents()); mem.Xml("a/b/c.xml", () => new XDocument(new XElement("first", "read"))); mem.UpdateXml("a/b/c.xml", new XDocument(new XElement("updated", "read"))); Assert.Equal( "<updated>read</updated>", mem.Xml("a/b/c.xml", () => throw new ApplicationException("This must not occur")).ToString() ); }
public void CachesOnUpdate() { var cache = new ConcurrentDictionary <string, XNode>(); var data = new CachedXmlContents( new RamContents(), cache, new ManyOf() ); data.UpdateXml("a/b/c.xml", new XDocument(new XElement("more", @"contents for everyone \o/"))); Assert.Contains("a/b/c.xml", cache.Keys); }