public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For <IApiConnection>(); var contentsClient = new RepositoryContentsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => contentsClient.GetArchiveLink(null, "name")); await Assert.ThrowsAsync <ArgumentNullException>(() => contentsClient.GetArchiveLink("owner", null)); await Assert.ThrowsAsync <ArgumentException>(() => contentsClient.GetArchiveLink("", "name")); await Assert.ThrowsAsync <ArgumentException>(() => contentsClient.GetArchiveLink("owner", "")); }
public async Task ReturnsArchiveLinkAsZipball() { var connection = Substitute.For<IApiConnection>(); connection.GetRedirect(Args.Uri).Returns(Task.FromResult("https://codeload.github.com/fake/repo/legacy.tar.gz/master")); var contentsClient = new RepositoryContentsClient(connection); var archiveLink = await contentsClient.GetArchiveLink("fake", "repo", ArchiveFormat.Zipball); connection.Received().GetRedirect(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/zipball/")); Assert.Equal("https://codeload.github.com/fake/repo/legacy.tar.gz/master", archiveLink); }
public async Task ReturnsArchiveLinkWithSpecifiedValues() { var connection = Substitute.For <IApiConnection>(); connection.GetRedirect(Args.Uri).Returns(Task.FromResult("https://codeload.github.com/fake/repo/legazy.zip/release")); var contentsClient = new RepositoryContentsClient(connection); var archiveLink = await contentsClient.GetArchiveLink("fake", "repo", ArchiveFormat.Zipball, "release"); connection.Received().GetRedirect(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/zipball/release")); Assert.Equal("https://codeload.github.com/fake/repo/legazy.zip/release", archiveLink); }
public async Task ReturnsArchiveLinkWithDefaults() { var connection = Substitute.For <IApiConnection>(); connection.GetRedirect(Args.Uri).Returns(Task.FromResult("https://codeload.github.com/fake/repo/legacy.tar.gz/master")); var contentsClient = new RepositoryContentsClient(connection); var archiveLink = await contentsClient.GetArchiveLink("fake", "repo"); connection.Received().GetRedirect(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/tarball/")); Assert.Equal("https://codeload.github.com/fake/repo/legacy.tar.gz/master", archiveLink); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For<IApiConnection>(); var contentsClient = new RepositoryContentsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => contentsClient.GetArchiveLink(null, "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => contentsClient.GetArchiveLink("owner", null)); await Assert.ThrowsAsync<ArgumentException>(() => contentsClient.GetArchiveLink("", "name")); await Assert.ThrowsAsync<ArgumentException>(() => contentsClient.GetArchiveLink("owner", "")); }