Exemple #1
0
            public void RequestsTheCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableGistsClient(gitHubClient);

                client.GetAllForUser("samthedev");

                gitHubClient.Connection.Received(1).Get <List <Gist> >(Arg.Is <Uri>(u => u.ToString() == "users/samthedev/gists"), Args.EmptyDictionary, null);
            }
Exemple #2
0
            public void RequestsTheCorrectUrlWithSince()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableGistsClient(gitHubClient);

                var since = DateTimeOffset.Now;
                var user  = "******";

                client.GetAllForUser(user, since);

                gitHubClient.Connection.Received(1).Get <List <Gist> >(Arg.Is <Uri>(u => u.ToString() == "users/samthedev/gists"), DictionaryWithSince, null);
            }
Exemple #3
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));
            }
Exemple #4
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.GetAllForUser("samthedev", options);

                gitHubClient.Connection.Received(1).Get <List <Gist> >(Arg.Is <Uri>(u => u.ToString() == "users/samthedev/gists"),
                                                                       DictionaryWithApiOptions, null);
            }
        public async Task ReturnsUserGists()
        {
            var gists = await _gistsClient.GetAllForUser(user).ToList();

            Assert.NotEmpty(gists);
        }