public async Task EnsureNonNullArguments() { var client = new StatisticsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetContributors(null, "name")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetContributors("owner", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetContributors("", "name")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetContributors("owner", "")); }
public void RequestsCorrectUrl() { var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/contributors", UriKind.Relative); var client = Substitute.For<IApiConnection>(); var statisticsClient = new StatisticsClient(client); statisticsClient.GetContributors("username","repositoryName"); client.Received().GetQueuedOperation<IEnumerable<Contributor>>(expectedEndPoint,Args.CancellationToken); }
public void RequestsCorrectUrl() { var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/contributors", UriKind.Relative); var client = Substitute.For <IApiConnection>(); var statisticsClient = new StatisticsClient(client); statisticsClient.GetContributors("username", "repositoryName"); client.Received().GetQueuedOperation <IEnumerable <Contributor> >(expectedEndPoint, Args.CancellationToken); }
public async Task RetrievesContributorsForCorrectUrl() { var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/contributors", UriKind.Relative); var client = Substitute.For<IApiConnection>(); IReadOnlyList<Contributor> contributors = new ReadOnlyCollection<Contributor>(new[] { new Contributor() }); client.GetQueuedOperation<Contributor>(expectedEndPoint, Args.CancellationToken) .Returns(Task.FromResult(contributors)); var statisticsClient = new StatisticsClient(client); var result = await statisticsClient.GetContributors("username", "repositoryName"); Assert.Equal(1, result.Count); }
public async Task RetrievesContributorsForCorrectUrl() { var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/contributors", UriKind.Relative); var client = Substitute.For <IApiConnection>(); IReadOnlyList <Contributor> contributors = new ReadOnlyCollection <Contributor>(new[] { new Contributor() }); client.GetQueuedOperation <Contributor>(expectedEndPoint, Args.CancellationToken) .Returns(Task.FromResult(contributors)); var statisticsClient = new StatisticsClient(client); var result = await statisticsClient.GetContributors("username", "repositoryName"); Assert.Equal(1, result.Count); }
public async Task RequestsCorrectUrlWithRepositoryId() { var expectedEndPoint = new Uri("repositories/1/stats/contributors", UriKind.Relative); IReadOnlyList<Contributor> contributors = new ReadOnlyCollection<Contributor>(new[] { new Contributor() }); var connection = Substitute.For<IApiConnection>(); connection.GetQueuedOperation<Contributor>(expectedEndPoint, Args.CancellationToken) .Returns(Task.FromResult(contributors)); var client = new StatisticsClient(connection); var result = await client.GetContributors(1); Assert.Equal(1, result.Count); }
public async Task RequestsCorrectUrlWithRepositoryId() { var expectedEndPoint = new Uri("repositories/1/stats/contributors", UriKind.Relative); IReadOnlyList <Contributor> contributors = new ReadOnlyCollection <Contributor>(new[] { new Contributor() }); var connection = Substitute.For <IApiConnection>(); connection.GetQueuedOperation <Contributor>(expectedEndPoint, Args.CancellationToken) .Returns(Task.FromResult(contributors)); var client = new StatisticsClient(connection); var result = await client.GetContributors(1); Assert.Equal(1, result.Count); }
public async Task ThrowsIfGivenNullRepositoryName() { var statisticsClient = new StatisticsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => statisticsClient.GetContributors("owner", null)); }
public async Task EnsureNonNullArguments() { var client = new StatisticsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetContributors(null, "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetContributors("owner", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetContributors("", "name")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetContributors("owner", "")); }
public async Task ThrowsIfGivenNullRepositoryName() { var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>()); await AssertEx.Throws<ArgumentNullException>(() => statisticsClient.GetContributors("owner", null)); }
public async Task ThrowsIfGivenNullOwner() { var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => statisticsClient.GetContributors(null, "repositoryName")); }
public async Task ThrowsIfGivenNullOwner() { var statisticsClient = new StatisticsClient(Substitute.For <IApiConnection>()); await AssertEx.Throws <ArgumentNullException>(() => statisticsClient.GetContributors(null, "repositoryName")); }