public ActionResult <RegisterUrlResponseBody> RegisterUrl([FromBody] RegisterUrlRequestBody request)
        {
            var accountClaim = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier);

            if (accountClaim == null)
            {
                return(Unauthorized());
            }
            var account = accountClaim.Value;

            if (account == null)
            {
                return(Unauthorized());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            RegisteredUrl           registeredUrl = _urlService.CreateRegisteredUrl(request, account);
            RegisterUrlResponseBody response      = new RegisterUrlResponseBody()
            {
                shortUrl = $"http://localhost:6500/{registeredUrl.ShortUrl}"
            };

            return(Created("", response));
        }
        public void RegiterUrl_OkResult()
        {
            InitializeControllerWithAuthorizedContext();
            _mockService.Setup(service => service.CreateRegisteredUrl(It.IsAny <RegisterUrlRequestBody>(), It.IsAny <string>()))
            .Returns(new RegisteredUrl()
            {
                LongUrl = "www.google.com", ShortUrl = "AStzHGv", AccountID = "54321"
            });

            RegisterUrlRequestBody request = new RegisterUrlRequestBody()
            {
                url = "www.google.com", redirectType = 301
            };

            var actionResult = _controller.RegisterUrl(request);

            Assert.IsType <ActionResult <RegisterUrlResponseBody> >(actionResult);

            OkObjectResult okResult = (OkObjectResult)actionResult.Result;

            Assert.IsType <OkObjectResult>((OkObjectResult)actionResult.Result);

            Assert.IsType <RegisterUrlResponseBody>(okResult.Value);

            RegisterUrlResponseBody response = (RegisterUrlResponseBody)okResult.Value;

            Assert.Equal("AStzHGv", response.shortUrl);
        }