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