Ejemplo n.º 1
0
        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")
                );
        }
Ejemplo n.º 2
0
        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()
                );
        }
Ejemplo n.º 3
0
        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);
        }