public async Task GetByShortenedUrlAsync_WhenMatchFound_ReturnsTargetUrl() { const string expectedTargetUrl = "https://localhost/target"; _urlServiceMock.Setup(m => m.GetByShortenedUrlAsync(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(new Url { TargetUrl = expectedTargetUrl }); var repository = new RedirectUrlRepository(_urlServiceMock.Object); var actual = await repository.GetByShortenedUrlAsync("https://localhost", "en"); Assert.Equal(expectedTargetUrl, actual.Url); }
public async Task GetByShortenedUrlAsync_WhenMatchNotFound_Throws() { var repository = new RedirectUrlRepository(_urlServiceMock.Object); await Assert.ThrowsAsync <InvalidOperationException>(() => repository.GetByShortenedUrlAsync("https://localhost", "en")); }