public async Task <ActionResult <GuidDataResponse> > CreateGuidData(GuidDataRequest request)
        {
            GuidDataRequestValidator.EnsureValid(request);

            var response = await _provider.CreateGuidData(request);

            return(Created($"{UriHelper.GetEncodedUrl(Request)}/{response.Guid}", response));
        }
示例#2
0
        public async Task Can_Create_Returns_GuidData_When_No_Guid_Given()
        {
            var guid       = Guid.NewGuid();
            var guidString = guid.ToString("N").ToUpper();
            var request    = new GuidDataRequest()
            {
                User = "******", Expire = DateTimeOffset.UtcNow.AddDays(30).ToUnixTimeSeconds().ToString()
            };

            _repoMock.CreateGuidData(Arg.Any <GuidData>()).Returns(new GuidData()
            {
                Guid = guid, User = request.User, Expire = long.Parse(request.Expire)
            });

            var actual = await _provider.CreateGuidData(request);

            Assert.NotNull(actual);
            Assert.Equal(guidString, actual.Guid);
            Assert.Equal(request.User, actual.User);
            Assert.Equal(request.Expire, actual.Expire);

            await _repoMock.Received(1).CreateGuidData(Arg.Any <GuidData>());
        }