public async Task CreateShortLink_InvalidInputUrl_ReturnNull(string inputUrl) { var sut = new ShortLinkService(_configurationMock, _dataProviderMock.Object, _hashidsMock.Object); var result = await sut.CreateShortLink(inputUrl).ConfigureAwait(false); Assert.Null(result); }
public async Task CreateSHortLink_DataProviderFailToCreateNewId_ReturnNull() { _dataProviderMock.Setup(x => x.GetUrlId(It.IsAny <string>())).ReturnsAsync((int?)null); _dataProviderMock.Setup(x => x.CreateUrlId("https://dummy.com")).ReturnsAsync((int?)null); var sut = new ShortLinkService(_configurationMock, _dataProviderMock.Object, _hashidsMock.Object); var result = await sut.CreateShortLink("https://dummy.com").ConfigureAwait(false); Assert.Null(result); }
public async Task CreateSHortLink_DataProviderReturnExistingId_ReturnShortLink() { _dataProviderMock.Setup(x => x.GetUrlId(It.IsAny <string>())).ReturnsAsync(10); _hashidsMock.Setup(x => x.Encode(10)).Returns("XYUNWEGFIH"); var sut = new ShortLinkService(_configurationMock, _dataProviderMock.Object, _hashidsMock.Object); var result = await sut.CreateShortLink("https://dummy.com").ConfigureAwait(false); Assert.NotNull(result); Assert.Equal("https://slinkweb.azurewebsites.net/XYUNWEGFIH", result); _dataProviderMock.Verify(x => x.CreateUrlId(It.IsAny <string>()), Times.Never); _hashidsMock.VerifyAll(); }