コード例 #1
0
            public async Task EnsureNonNullArguments()
            {
                var client = new StatisticsClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetCommitActivity(null, "name"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetCommitActivity("owner", null));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetCommitActivity("", "name"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetCommitActivity("owner", ""));
            }
コード例 #2
0
            public void RequestsCorrectUrl()
            {
                var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/commit_activity", UriKind.Relative);

                var client = Substitute.For<IApiConnection>();
                var statisticsClient = new StatisticsClient(client);

                statisticsClient.GetCommitActivity("username", "repositoryName");

                client.Received().GetQueuedOperation<IEnumerable<WeeklyCommitActivity>>(expectedEndPoint, Args.CancellationToken);
            }
コード例 #3
0
            public void RequestsCorrectUrl()
            {
                var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/commit_activity", UriKind.Relative);

                var client           = Substitute.For <IApiConnection>();
                var statisticsClient = new StatisticsClient(client);

                statisticsClient.GetCommitActivity("username", "repositoryName");

                client.Received().GetQueuedOperation <IReadOnlyList <WeeklyCommitActivity> >(expectedEndPoint, Args.CancellationToken);
            }
コード例 #4
0
            public async Task RequestsCorrectUrl()
            {
                var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/commit_activity", UriKind.Relative);

                var data = new WeeklyCommitActivity(new[] { 1, 2 }, 100, 42);
                IReadOnlyList<WeeklyCommitActivity> response = new ReadOnlyCollection<WeeklyCommitActivity>(new[] { data });
                var client = Substitute.For<IApiConnection>();
                client.GetQueuedOperation<WeeklyCommitActivity>(expectedEndPoint, Args.CancellationToken)
                    .Returns(Task.FromResult(response));
                var statisticsClient = new StatisticsClient(client);

                var result = await statisticsClient.GetCommitActivity("username", "repositoryName");

                Assert.Equal(2, result.Activity[0].Days.Count);
                Assert.Equal(1, result.Activity[0].Days[0]);
                Assert.Equal(2, result.Activity[0].Days[1]);
                Assert.Equal(100, result.Activity[0].Total);
                Assert.Equal(42, result.Activity[0].Week);
            }
コード例 #5
0
            public async Task RequestsCorrectUrl()
            {
                var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/commit_activity", UriKind.Relative);

                var data = new WeeklyCommitActivity(new[] { 1, 2 }, 100, 42);
                IReadOnlyList <WeeklyCommitActivity> response = new ReadOnlyCollection <WeeklyCommitActivity>(new[] { data });
                var client = Substitute.For <IApiConnection>();

                client.GetQueuedOperation <WeeklyCommitActivity>(expectedEndPoint, Args.CancellationToken)
                .Returns(Task.FromResult(response));
                var statisticsClient = new StatisticsClient(client);

                var result = await statisticsClient.GetCommitActivity("username", "repositoryName");

                Assert.Equal(2, result.Activity[0].Days.Count);
                Assert.Equal(1, result.Activity[0].Days[0]);
                Assert.Equal(2, result.Activity[0].Days[1]);
                Assert.Equal(100, result.Activity[0].Total);
                Assert.Equal(42, result.Activity[0].Week);
            }
コード例 #6
0
 public async Task ThrowsIfGivenNullRepositoryName()
 {
     var statisticsClient = new StatisticsClient(Substitute.For <IApiConnection>());
     await Assert.ThrowsAsync <ArgumentNullException>(() => statisticsClient.GetCommitActivity("owner", null));
 }
コード例 #7
0
            public async Task EnsureNonNullArguments()
            {
                var client = new StatisticsClient(Substitute.For<IApiConnection>());

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetCommitActivity(null, "name"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetCommitActivity("owner", null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetCommitActivity("", "name"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetCommitActivity("owner", ""));
            }
コード例 #8
0
 public async Task ThrowsIfGivenNullRepositoryName()
 {
     var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
     await AssertEx.Throws<ArgumentNullException>(() => statisticsClient.GetCommitActivity("owner", null));
 }
コード例 #9
0
 public async Task ThrowsIfGivenNullOwner()
 {
     var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
     await Assert.ThrowsAsync<ArgumentNullException>(() => statisticsClient.GetCommitActivity(null, "repositoryName"));
 }
コード例 #10
0
 public async Task ThrowsIfGivenNullOwner()
 {
     var statisticsClient = new StatisticsClient(Substitute.For <IApiConnection>());
     await AssertEx.Throws <ArgumentNullException>(() => statisticsClient.GetCommitActivity(null, "repositoryName"));
 }