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); }