コード例 #1
0
            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", ""));
            }
コード例 #2
0
            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);
            }
コード例 #3
0
            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);
            }
コード例 #4
0
            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);
            }
コード例 #5
0
            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);
            }
コード例 #6
0
            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);
            }
コード例 #7
0
            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);
            }
コード例 #8
0
 public async Task ThrowsIfGivenNullRepositoryName()
 {
     var statisticsClient = new StatisticsClient(Substitute.For <IApiConnection>());
     await Assert.ThrowsAsync <ArgumentNullException>(() => statisticsClient.GetContributors("owner", null));
 }
コード例 #9
0
            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", ""));
            }
コード例 #10
0
 public async Task ThrowsIfGivenNullRepositoryName()
 {
     var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
     await AssertEx.Throws<ArgumentNullException>(() => statisticsClient.GetContributors("owner", null));
 }
コード例 #11
0
 public async Task ThrowsIfGivenNullOwner()
 {
     var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
     await Assert.ThrowsAsync<ArgumentNullException>(() => statisticsClient.GetContributors(null, "repositoryName"));
 }
コード例 #12
0
 public async Task ThrowsIfGivenNullOwner()
 {
     var statisticsClient = new StatisticsClient(Substitute.For <IApiConnection>());
     await AssertEx.Throws <ArgumentNullException>(() => statisticsClient.GetContributors(null, "repositoryName"));
 }