Example #1
0
        public void SaveUrl_WhenTheUrlIsNotOnline_ReturnMessageNotOnline()
        {
            //Arrange
            var utilities = new Utilities();

            //Act
            var shortUrlServices = new ShortUrlServices(_uow.Object, utilities);
            var result           = shortUrlServices.SaveUrl("https://consent.yahoo.com/collectConsent?sessionId=1_cc-session_784f6a09-07d7-41e1-b3e7-aa40f356cd1e&lang=en-GB&inline=false");

            //Assert
            Assert.That(result, Is.EqualTo("Sorry the URL you entered is not live"));
        }
Example #2
0
        public void SaveUrl_WhenTheUrlIsOnline_GetRandomUrlAndCompleteShouldBeTouched()
        {
            //Act
            _utilities.Setup(x => x.IsValidUri("")).Returns(Task.FromResult(true));
            _uow.Setup(x => x.ShortUrlRepository.IsShortUrlExists("")).Returns(false);
            var shortUrlServices = new ShortUrlServices(_uow.Object, _utilities.Object);
            var saveResult       = shortUrlServices.SaveUrl("");


            //Assert
            _utilities.Verify(x => x.GetRandomUrl(), Times.Once);
            _uow.Verify(x => x.Complete(), Times.Once);
            Assert.That(saveResult, Is.EqualTo(""));
        }