Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }