예제 #1
0
        public void RemovesBytesFromCacheIfEmpty()
        {
            var bytesCache = new ConcurrentDictionary <string, byte[]>();
            var contents   = new CachedByteContents(new RamContents(), bytesCache, 8, new ManyOf());

            contents.Bytes("a/b/c.dat", () => new byte[1] {
                0x12
            });
            contents.UpdateBytes("a/b/c.dat", new byte[0]);

            Assert.False(
                bytesCache.ContainsKey("a/b/c.xml")
                );
        }
예제 #2
0
        public void DoesNotCacheBytes()
        {
            var mem    = new ConcurrentDictionary <string, byte[]>();
            var cached = new CachedByteContents(new RamContents(mem), 1024);

            cached.Bytes("a/b/c.dat", () => new byte[0]).ToString();

            byte[] unused;
            mem.TryRemove("a/b/c.dat", out unused);

            Assert.Throws <ApplicationException>(() =>
                                                 cached.Xml("a/b/c.dat", () => throw new ApplicationException()).ToString()
                                                 );
        }