public async Task Test_InflateAction_NullInput() { // Setup var urlShortnerServiceMock = new Mock <IUrlShortnerService>(); var mapperMock = new Mock <IMapper>(); //urlShortnerServiceMock.Setup(s => s.InflateShortenedUrl(It.IsAny<string>())) // .Returns(Task.FromResult<string>(null)); var urlController = new UrlController(urlShortnerServiceMock.Object, mapperMock.Object); var result = await urlController.Inflate("sds"); // Assert Assert.IsTrue(result is NotFoundResult); }
public async Task Test_InflateAction_ValidHash() { // Setup const string originalUrl = "http://example.com"; var urlShortnerServiceMock = new Mock <IUrlShortnerService>(); var mapperMock = new Mock <IMapper>(); urlShortnerServiceMock.Setup(s => s.InflateShortenedUrl(It.IsAny <string>())) .Returns(Task.FromResult <string>(originalUrl)); // Action var urlController = new UrlController(urlShortnerServiceMock.Object, mapperMock.Object); var result = await urlController.Inflate("sds"); // Assert Assert.IsTrue(result is OkObjectResult); Assert.AreEqual(((OkObjectResult)result).Value, originalUrl); }