示例#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", ""));
            }
            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);
            }
            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);
            }
            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);
            }
            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);
            }
 public async Task ThrowsIfGivenNullRepositoryName()
 {
     var statisticsClient = new StatisticsClient(Substitute.For <IApiConnection>());
     await Assert.ThrowsAsync <ArgumentNullException>(() => statisticsClient.GetCommitActivity("owner", null));
 }
            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", ""));
            }
 public async Task ThrowsIfGivenNullRepositoryName()
 {
     var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
     await AssertEx.Throws<ArgumentNullException>(() => statisticsClient.GetCommitActivity("owner", null));
 }
 public async Task ThrowsIfGivenNullOwner()
 {
     var statisticsClient = new StatisticsClient(Substitute.For<IApiConnection>());
     await Assert.ThrowsAsync<ArgumentNullException>(() => statisticsClient.GetCommitActivity(null, "repositoryName"));
 }
 public async Task ThrowsIfGivenNullOwner()
 {
     var statisticsClient = new StatisticsClient(Substitute.For <IApiConnection>());
     await AssertEx.Throws <ArgumentNullException>(() => statisticsClient.GetCommitActivity(null, "repositoryName"));
 }