Exemplo n.º 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")
                );
        }
        public void RemovesFromCacheIfOversizedSecondTime()
        {
            var cache    = new ConcurrentDictionary <string, byte[]>();
            var contents =
                new CachedByteContents(
                    new RamContents(
                        new KeyValuePair <string, byte[]>("a/b/c.dat", new byte[1] {
                0x13
            })
                        ),
                    cache,
                    1,
                    new ManyOf()
                    );

            contents.UpdateBytes("a/b/c.dat", new byte[0]);

            Assert.DoesNotContain("a/b/c.dat", cache.Keys);
        }