예제 #1
0
        public void AsyncCache_Auto_Created()
        {
            _cache.Clear();

            for (var i = 0; i < TestCount; i++)
            {
                Assert.AreEqual(Math.Pow(i, 2), _cache[i]);
            }
        }
예제 #2
0
        public async Task ShouldAwaitDataSourceTaskTwiceSinceCacheKeyWasCleared()
        {
            //Arrange
            int callCount = 0;

            //Act
            await cache.Get(key : "some key", dataSource : () => { callCount++; return(Task.FromResult(2)); });

            cache.Clear(key: "some key");
            var result = await cache.Get(key : "some key", dataSource : () => { callCount++; return(Task.FromResult(3)); });

            //Assert
            callCount.Should().Be(2);
            result.Should().Be(3);
        }