public async Task Can_Get_Returns_GuidData_When_Guid_Exist() { var guid = Guid.NewGuid(); var guidString = guid.ToString("N").ToUpper(); var raw = new { user = "******", expire = DateTimeOffset.UtcNow.AddDays(30).ToUnixTimeSeconds().ToString() }; _repoMock.GetGuidData(Arg.Is <Guid>(x => x == guid)).Returns((new GuidData() { Guid = guid, User = raw.user, Expire = long.Parse(raw.expire) })); var actual = await _provider.GetGuidData(guidString); Assert.NotNull(actual); Assert.Equal(guidString, actual.Guid); Assert.Equal(raw.user, actual.User); Assert.Equal(raw.expire, actual.Expire); await _repoMock.Received(1).GetGuidData(Arg.Any <Guid>()); }
public async Task <ActionResult <GuidDataResponse> > GetGuidData(string guid) { GuidValidator.EnsureValid(guid); var response = await _provider.GetGuidData(guid); if (response != null) { return(Ok(response)); } else { return(NotFound()); } }