public async void Can_Get_From_Cache_After_Cached() { var guid = Guid.NewGuid(); var guidString = guid.ToString("N").ToUpper(); var raw = new GuidData { Guid = guid, User = "******", Expire = DateTimeOffset.UtcNow.AddDays(30).ToUnixTimeSeconds() }; var cached = JsonConvert.SerializeObject(raw); _cacheMock.GetAsync(Arg.Is <string>(x => x == "GuidData_" + guidString)).Returns(Encoding.ASCII.GetBytes(cached)); var actual = await _repo.GetGuidData(guid); Assert.NotNull(actual); Assert.Equal(guid, actual.Guid); await _dbMock.DidNotReceive().GetGuidData(Arg.Any <Guid>()); }
public async Task Can_Get_Returns_400_BadRequest_When_No_Guid_Given() { var guid = Guid.NewGuid(); var guidString = guid.ToString("N").ToUpper(); var raw = new { user = "******", expire = DateTimeOffset.UtcNow.AddDays(30).ToUnixTimeSeconds().ToString() }; var req = GetHttpRequestMessage(raw, $"guid/", HttpMethod.Get); var resp = await _client.SendAsync(req); Assert.Equal(HttpStatusCode.MethodNotAllowed, resp.StatusCode); var actual = JsonConvert.DeserializeObject <ValidationProblemDetails>(await resp.Content.ReadAsStringAsync()); Assert.Null(actual); await _repoMock.DidNotReceive().GetGuidData(Arg.Any <Guid>()); }