コード例 #1
0
        public async Task <IActionResult> Get([RegularExpression(@"[0-9]{9}")] string id)
        {
            var orgData = await _cache.GetOrCreateAsync(id, cacheEntry =>
            {
                cacheEntry.AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(30);
                cacheEntry.Size = 1;
                return(_service.GetOrgDataById(id));
            });

            if (orgData is null)
            {
                return(NotFound($"Organization with id: {id} not found"));
            }

            return(Ok(orgData));
        }
コード例 #2
0
        public async Task Get_OrgData_WithValid_RequestParameter_ShouldReturn_OrgDataObject(string validId)
        {
            var orgData = await _service.GetOrgDataById(validId);

            orgData.Should().BeOfType <OrgData>();
        }