Beispiel #1
0
        public async Task Can_Upsert_Returns_GuidData_Using_30_Days_Expire_When_No_Expire_Given()
        {
            var guid       = Guid.NewGuid();
            var guidString = guid.ToString("N").ToUpper();
            var request    = new GuidDataRequest()
            {
                User = "******", Expire = null
            };

            long autoGeneratedExpire = 0;

            await _repoMock.UpsertGuidData(Arg.Do <GuidData>(x => autoGeneratedExpire = x.Expire));

            var actual = await _provider.UpsertGuidData(guidString, request);

            Assert.True(autoGeneratedExpire > 0);

            await _repoMock.Received(1).UpsertGuidData(Arg.Any <GuidData>());
        }
        public async Task <ActionResult <GuidDataResponse> > UpsertGuidData(string guid, GuidDataRequest request)
        {
            GuidValidator.EnsureValid(guid);
            GuidDataRequestValidator.EnsureValid(request);

            var(response, isUpdated) = await _provider.UpsertGuidData(guid, request);

            if (isUpdated)
            {
                return(Ok(response));
            }
            else
            {
                return(Created(UriHelper.GetEncodedUrl(Request), response));
            }
        }