コード例 #1
0
            public void EnsuresNonNullArguments()
            {
                var gitsClient = new ObservableGistsClient(Substitute.For <IGitHubClient>());

                Assert.Throws <ArgumentNullException>(() => gitsClient.GetAllCommits(null));
                Assert.Throws <ArgumentException>(() => gitsClient.GetAllCommits(""));
                Assert.Throws <ArgumentNullException>(() => gitsClient.GetAllCommits("id", null));
                Assert.Throws <ArgumentException>(() => gitsClient.GetAllCommits("", ApiOptions.None));
            }
コード例 #2
0
            public async Task EnsureNonNullArguments()
            {
                var client = new ObservableGistsClient(Substitute.For <IGitHubClient>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllCommits(null).ToTask());

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllCommits("").ToTask());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForks(null).ToTask());

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForks("").ToTask());
            }
コード例 #3
0
            public void RequestsTheCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableGistsClient(gitHubClient);

                client.GetAllCommits("id");

                gitHubClient.Connection.Received(1).Get <List <GistHistory> >(Arg.Is <Uri>(u => u.ToString() == "gists/id/commits"), Args.EmptyDictionary, null);
            }
コード例 #4
0
            public void RequestsCorrectGetCommitsUrl()
            {
                var github   = Substitute.For <IGitHubClient>();
                var client   = new ObservableGistsClient(github);
                var expected = new Uri("gists/9257657/commits", UriKind.Relative);

                client.GetAllCommits("9257657");

                github.Connection.Received(1).Get <List <GistHistory> >(expected, Arg.Any <IDictionary <string, string> >(), null);
            }
コード例 #5
0
            public void RequestsTheCorrectUrlWithApiOptions()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableGistsClient(gitHubClient);

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

                client.GetAllCommits("id", options);

                gitHubClient.Connection.Received(1).Get <List <GistHistory> >(Arg.Is <Uri>(u => u.ToString() == "gists/id/commits"),
                                                                              DictionaryWithApiOptions, null);
            }
コード例 #6
0
        public async Task ReturnsGistCommits()
        {
            var gistCommits = await _gistsClient.GetAllCommits(gistId).ToList();

            Assert.NotEmpty(gistCommits);
        }