Example #1
0
        public async Task with_an_empty_url()
        {
            var repo      = new Mock <IModifiedUrlRepository>().Object;
            var idService = new Mock <IIdService>().Object;

            var controller = new TestModifiedUrlController(repo, idService);

            var result = (await controller.GetOriginalUrl("").ConfigureAwait(false)).Result as BadRequestObjectResult;

            Assert.NotNull(result);
        }
Example #2
0
        public async Task with_a_valid_url()
        {
            var repo     = new Mock <IModifiedUrlRepository>();
            var response = new OriginalUrlResponseDto()
            {
                OriginalUrl = Guid.NewGuid().ToString()
            };

            repo.Setup(rep => rep.GetOriginalUrl(It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(response);

            var controller = new TestModifiedUrlController(repo.Object, new Mock <IIdService>().Object);

            var result = (await controller.GetOriginalUrl(Guid.NewGuid().ToString()).ConfigureAwait(false)).Result as OkObjectResult;

            Assert.NotNull(result);

            var value = result.Value as OriginalUrlResponse;

            Assert.NotNull(value);

            Assert.AreEqual(response.OriginalUrl, value.OriginalUrl);
        }