public void RequestsCorrectUrlWithRepositoryId()
            {
                var githubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryCommentsClient(githubClient);

                client.GetAllForRepository(1);
                githubClient.Connection.Received(1).Get <List <CommitComment> >(Arg.Is <Uri>(uri => uri.ToString() == "repositories/1/comments"),
                                                                                Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview");
            }
            public void EnsuresNonNullArguments()
            {
                var githubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryCommentsClient(githubClient);

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

                Assert.Throws <ArgumentNullException>(() => client.GetAllForRepository(1, null));

                Assert.Throws <ArgumentException>(() => client.GetAllForRepository("", "name"));
                Assert.Throws <ArgumentException>(() => client.GetAllForRepository("owner", ""));
                Assert.Throws <ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None));
            }
예제 #3
0
            public void RequestsCorrectUrl()
            {
                var githubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryCommentsClient(githubClient);

                client.GetAllForRepository("fake", "repo");
                githubClient.Connection.Received(1).Get <List <CommitComment> >(Arg.Is <Uri>(uri => uri.ToString() == "repos/fake/repo/comments"),
                                                                                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.GetAllForRepository("fake", "repo", options);
                githubClient.Connection.Received(1).Get <List <CommitComment> >(Arg.Is <Uri>(uri => uri.ToString() == "repos/fake/repo/comments"),
                                                                                Arg.Is <Dictionary <string, string> >(dictionary => dictionary.Count == 2), "application/vnd.github.squirrel-girl-preview");
            }
예제 #5
0
            public void RequestsCorrectUrlWithRepositoryIdWithApiOptions()
            {
                var githubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryCommentsClient(githubClient);

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

                client.GetAllForRepository(1, options);
                githubClient.Connection.Received(1).Get <List <CommitComment> >(Arg.Is <Uri>(uri => uri.ToString() == "repositories/1/comments"),
                                                                                Arg.Is <Dictionary <string, string> >(dictionary => dictionary.Count == 2), null);
            }