public async Task EnsuresNonNullArguments() { var client = new RepositoryTrafficClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllReferrers(null, "name")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllReferrers("owner", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllReferrers("", "name")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllReferrers("owner", "")); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryTrafficClient(connection); await client.GetAllReferrers(1); connection.Received().GetAll <RepositoryTrafficReferrer>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/traffic/popular/referrers"), "application/vnd.github.spiderman-preview"); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryTrafficClient(connection); await client.GetAllReferrers("fake", "repo"); connection.Received().GetAll <RepositoryTrafficReferrer>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/traffic/popular/referrers")); }