Пример #1
0
        public void Find()
        {
            // Act
            var abc = _customersRepository.Find("1");
            var def = _customersRepository.Find("2");
            var ghi = _customersRepository.Find("3");

            // Assert
            Assert.IsNotNull(abc);
            Assert.IsNotNull(def);
            Assert.IsNull(ghi);

            Assert.AreEqual("abc", abc.CompanyName);
            Assert.AreEqual("def", def.CompanyName);
        }
        public async Task <string> GetSymbol([FromQuery] string symbolCode)
        {
            var cacheKey = "Life".GenerateCacheKey("GetSymbol", "Get");
            var symbol   = await _cache.GetStringAsync(cacheKey).ConfigureAwait(false);

            if (symbol == null)
            {
                symbol = _customersRepository.Find(symbolCode).Name;

                await _cache.SetStringAsync(cacheKey, symbol, new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMilliseconds(10 * 1000) })
                .ConfigureAwait(false);
            }

            return(symbol);
        }