コード例 #1
0
            public void RequestsCorrectUrl()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryCommentsClient(githubClient);

                client.GetAllForCommit("fake", "repo", "sha1");
                githubClient.Received().Repository.Comment.GetAllForCommit("fake", "repo", "sha1", Args.ApiOptions);
            }
            public void EnsuresNonNullArguments()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryCommentsClient(githubClient);

                Assert.Throws<ArgumentNullException>(() => client.GetAllForCommit(null, "name", "sha"));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForCommit("owner", null, "sha"));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForCommit("owner", "name", null));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForCommit(null, "name", "sha", ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForCommit("owner", null, "sha", ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForCommit("owner", "name", null, ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForCommit("owner", "name", "sha", null));

                Assert.Throws<ArgumentNullException>(() => client.GetAllForCommit(1, null, ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForCommit(1, "sha", null));

                Assert.Throws<ArgumentException>(() => client.GetAllForCommit("", "name", "sha"));
                Assert.Throws<ArgumentException>(() => client.GetAllForCommit("owner", "", "sha"));
                Assert.Throws<ArgumentException>(() => client.GetAllForCommit("owner", "name", ""));
                Assert.Throws<ArgumentException>(() => client.GetAllForCommit("", "name", "sha", ApiOptions.None));
                Assert.Throws<ArgumentException>(() => client.GetAllForCommit("owner", "", "sha", ApiOptions.None));
                Assert.Throws<ArgumentException>(() => client.GetAllForCommit("owner", "name", "", ApiOptions.None));

                Assert.Throws<ArgumentException>(() => client.GetAllForCommit(1, "", ApiOptions.None));
            }
            public void RequestsCorrectUrlWithRepositoryIdWithApiOptions()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryCommentsClient(githubClient);

                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize = 1
                };

                client.GetAllForCommit(1, "sha", options);
                githubClient.Connection.Received().Get<List<CommitComment>>(Arg.Is(new Uri("repositories/1/commits/sha/comments", UriKind.Relative)), 
                    Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null);
            }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryCommentsClient(githubClient);

                client.GetAllForCommit(1, "sha");
                githubClient.Connection.Received().Get<List<CommitComment>>(Arg.Is(new Uri("repositories/1/commits/sha/comments", UriKind.Relative)),
                    Args.EmptyDictionary, null);
            }
            public void RequestsCorrectUrlWithApiOptions()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryCommentsClient(githubClient);

                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize = 1
                };

                client.GetAllForCommit("fake", "repo", "sha", options);
                githubClient.Connection.Received().Get<List<CommitComment>>(Arg.Is(new Uri("repos/fake/repo/commits/sha/comments", UriKind.Relative)),
                    Arg.Is<IDictionary<string, string>>(d => d.Count == 2), "application/vnd.github.squirrel-girl-preview");
            }
            public void RequestsCorrectUrl()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryCommentsClient(githubClient);

                client.GetAllForCommit("fake", "repo", "sha");
                githubClient.Connection.Received().Get<List<CommitComment>>(Arg.Is(new Uri("repos/fake/repo/commits/sha/comments", UriKind.Relative)),
                    Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview");
            }
コード例 #7
0
            public void RequestsCorrectUrlWithApiOptions()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryCommentsClient(githubClient);

                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize = 1
                };

                client.GetAllForCommit("fake", "repo", "sha1", options);
                githubClient.Received().Repository.Comment.GetAllForCommit("fake", "repo", "sha1", options);
            }