예제 #1
0
            public void EnsuresNonNullArguments()
            {
                var gitsClient = new ObservableGistsClient(Substitute.For <IGitHubClient>());

                Assert.Throws <ArgumentNullException>(() => gitsClient.GetAllStarred(null));
                Assert.Throws <ArgumentNullException>(() => gitsClient.GetAllStarred(DateTimeOffset.Now, null));
            }
예제 #2
0
            public void EnsuresNonNullArguments()
            {
                var gitsClient = new ObservableGistsClient(Substitute.For <IGitHubClient>());

                Assert.Throws <ArgumentNullException>(() => gitsClient.GetAllForks(null));
                Assert.Throws <ArgumentException>(() => gitsClient.GetAllForks(""));
                Assert.Throws <ArgumentNullException>(() => gitsClient.GetAllForks("id", null));
                Assert.Throws <ArgumentException>(() => gitsClient.GetAllForks("", ApiOptions.None));
            }
예제 #3
0
            public void RequestsTheCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableGistsClient(gitHubClient);

                client.GetAllForks("id");

                gitHubClient.Connection.Received(1).Get <List <GistFork> >(new Uri("gists/id/forks", UriKind.Relative), Args.EmptyDictionary, null);
            }
예제 #4
0
            public void RequestsTheCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableGistsClient(gitHubClient);

                client.GetAll();

                gitHubClient.Connection.Received(1).Get <List <Gist> >(Arg.Is <Uri>(u => u.ToString() == "gists"), Args.EmptyDictionary, null);
            }
예제 #5
0
            public void RequestsCorrectGetForksUrl()
            {
                var github   = Substitute.For <IGitHubClient>();
                var client   = new ObservableGistsClient(github);
                var expected = new Uri("gists/9257657/forks", UriKind.Relative);

                client.GetAllForks("9257657");

                github.Connection.Received(1).Get <List <GistFork> >(expected, Arg.Any <IDictionary <string, string> >(), null);
            }
예제 #6
0
            public void RequestsTheCorrectUrlWithSince()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableGistsClient(gitHubClient);

                var since = DateTimeOffset.Now;

                client.GetAll(since);

                gitHubClient.Connection.Received(1).Get <List <Gist> >(Arg.Is <Uri>(u => u.ToString() == "gists"), DictionaryWithSince, null);
            }
예제 #7
0
            public void EnsuresNonNullArguments()
            {
                var gitsClient = new ObservableGistsClient(Substitute.For <IGitHubClient>());

                Assert.Throws <ArgumentNullException>(() => gitsClient.GetAllForUser(null));
                Assert.Throws <ArgumentException>(() => gitsClient.GetAllForUser(""));
                Assert.Throws <ArgumentNullException>(() => gitsClient.GetAllForUser(null, DateTimeOffset.Now));
                Assert.Throws <ArgumentException>(() => gitsClient.GetAllForUser("", DateTimeOffset.Now));
                Assert.Throws <ArgumentNullException>(() => gitsClient.GetAllForUser("samthedev", DateTimeOffset.Now, null));
                Assert.Throws <ArgumentException>(() => gitsClient.GetAllForUser("", DateTimeOffset.Now, ApiOptions.None));
            }
예제 #8
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());
            }
예제 #9
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.GetAll(options);

                gitHubClient.Connection.Received(1).Get <List <Gist> >(Arg.Is <Uri>(u => u.ToString() == "gists"),
                                                                       DictionaryWithApiOptions, null);
            }
예제 #10
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.GetAllForks("id", options);

                gitHubClient.Connection.Received(1).Get <List <GistFork> >(new Uri("gists/id/forks", UriKind.Relative),
                                                                           DictionaryWithApiOptions, null);
            }
예제 #11
0
            public void RequestsTheCorrectUrlWithSinceAndApiOptions()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableGistsClient(gitHubClient);

                var options = new ApiOptions()
                {
                    PageCount = 1,
                    PageSize  = 1,
                    StartPage = 1
                };
                var since = DateTimeOffset.Now;

                client.GetAllStarred(since, options);

                gitHubClient.Connection.Received(1).Get <List <Gist> >(Arg.Is <Uri>(u => u.ToString() == "gists/starred"),
                                                                       DictionaryWithApiOptionsAndSince, null);
            }
예제 #12
0
        public TheGetAllForksMethod()
        {
            var github = Helper.GetAuthenticatedClient();

            _gistsClient = new ObservableGistsClient(github);
        }