Exemplo n.º 1
0
        public void Should_Use_Factory_Only_If_The_Value_Was_Not_Present()
        {
            //The key is already present, so it doesn't use the factory to create a new one
            Assert.Equal("TestValue1", StaticCache.GetOrAdd("TestKey1", () => "TestValue1_Changed"));

            StaticCache.Remove("TestKey1");

            //The key is not present, so it uses the factory to create a new one
            Assert.Equal("TestValue1_Changed", StaticCache.GetOrAdd("TestKey1", () => "TestValue1_Changed"));
        }