Ejemplo n.º 1
0
        public void GetSet_lambda_is_always_called()
        {
            // Arrange
            var sut   = new PassThroughCache();
            var count = 0;

            // Act
            var result = sut.GetSet("testKey", () => { count++; return("41"); }, TimeSpan.FromSeconds(10));

            result = sut.GetSet("testKey", () => { count++; return("42"); }, TimeSpan.FromSeconds(10));

            // Assert
            Assert.Equal("42", result);
            Assert.Equal(2, count);
        }
Ejemplo n.º 2
0
        private StaticDataEndpoints(bool useCache = true)
        {
            Requesters.StaticApiRequester = new Requester();

            ICache cache = null;

            if (useCache)
            {
                cache = new Cache();
            }
            else
            {
                cache = new PassThroughCache();
            }

            InitializeEndpoints(new StaticEndpointProvider(Requesters.StaticApiRequester, cache));
        }
        private StaticDataEndpoints(string apiKey, bool useCache = true)
        {
            Requesters.StaticApiRequester = new RateLimitedRequester(apiKey, new Dictionary <TimeSpan, int>
            {
                { new TimeSpan(1, 0, 0), 10 }
            });

            ICache cache = null;

            if (useCache)
            {
                cache = new Cache();
            }
            else
            {
                cache = new PassThroughCache();
            }

            InitializeEndpoints(new StaticEndpointProvider(Requesters.StaticApiRequester, cache));
        }