Ejemplo n.º 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);
            }
Ejemplo n.º 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);
            }
Ejemplo n.º 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));
            }
Ejemplo n.º 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);
            }
Ejemplo n.º 5
0
        public async Task ReturnsUserGists()
        {
            var gists = await _gistsClient.GetAllForUser(user).ToList();

            Assert.NotEmpty(gists);
        }