Exemple #1
0
        public void GetTheResponseUrl_WhenTheShortLinkExistsAnyTheOriginalLinkIsNotLive_ReturnTheOriginal()
        {
            //Act
            _uow.Setup(x => x.ShortUrlRepository.GetByShortKey("")).Returns(new ShortUrl());
            _utilities.Setup(x => x.GetTheResponseFromTheRequestedUrl("")).Returns(Task.FromResult <string>(null));
            var shortUrlServices = new ShortUrlServices(_uow.Object, _utilities.Object);
            var result           = shortUrlServices.GetTheResponseUrl("", 3);

            //Assert
            Assert.That(result.ErrorMessage, Does.Contain("is not live"));
            Assert.That(result.ResponseUrl, Is.EqualTo(null));
        }
Exemple #2
0
        public void GetTheResponseUrl_WhenTheShortLinkNotExists_ReturnTheUrlYouEnterEDIsNotExist()
        {
            //Arrange
            var responseResult = new ResponseResultVm
            {
                ErrorMessage = "The Url you entered is not exist",
                ResponseUrl  = null
            };

            //Act
            _uow.Setup(x => x.ShortUrlRepository.GetByShortKey("")).Returns((ShortUrl)null);
            var shortUrlServices = new ShortUrlServices(_uow.Object, _utilities.Object);
            var result           = shortUrlServices.GetTheResponseUrl("", 3);

            _utilities.Verify(x => x.GetTheResponseFromTheRequestedUrl(""), Times.Never);

            //Assert
            Assert.That(result.ErrorMessage, Is.EqualTo(responseResult.ErrorMessage));
            Assert.That(result.ResponseUrl, Is.EqualTo(responseResult.ResponseUrl));
        }
Exemple #3
0
        public void GetTheResponseUrl_WhenTheLinkIsNotValidAnyMore_ReturnTheUrlYouEnterEDNotValidAnyMore()
        {
            //Arrange
            var responseResult = new ResponseResultVm
            {
                ErrorMessage = "The Url you entered is not exist",
                ResponseUrl  = null
            };



            //Act
            _uow.Setup(x => x.ShortUrlRepository.GetByShortKey("")).Returns(new ShortUrl());
            _utilities.Setup(x => x.MonthsDifferenceBetweenTwoDates(new DateTime(), new DateTime())).Returns(4);
            var shortUrlServices = new ShortUrlServices(_uow.Object, _utilities.Object);
            var result           = shortUrlServices.GetTheResponseUrl("", 3);

            _utilities.Verify(x => x.GetTheResponseFromTheRequestedUrl(""), Times.Never);


            //Assert
            Assert.That(result.ErrorMessage, Does.Contain("is not live"));
            Assert.That(result.ResponseUrl, Is.EqualTo(responseResult.ResponseUrl));
        }