Beispiel #1
0
            public async Task EnsuresArgumentsNotNull()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableEventsClient(gitHubClient);

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name").ToTask());

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name").ToTask());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null).ToTask());

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "").ToTask());
            }
Beispiel #2
0
            public void RequestsCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableEventsClient(gitHubClient);

                client.GetAllForRepository("fake", "repo");

                gitHubClient.Connection.Received(1).Get <List <Activity> >(new Uri("repos/fake/repo/events", UriKind.Relative), Args.EmptyDictionary, null);
            }
Beispiel #3
0
            public void EnsuresNonNullArguments()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableEventsClient(gitHubClient);

                Assert.Throws <ArgumentNullException>(() => client.GetAllForRepository(null, "name"));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForRepository("owner", null));
                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(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));
            }
            public void RequestsCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableEventsClient(gitHubClient);

                client.GetAllForRepository("fake", "repo");

                gitHubClient.Connection.GetAsync <IReadOnlyList <Activity> >(new Uri("repos/fake/repo/issues/events", UriKind.Relative), null, null);
            }
Beispiel #5
0
            public void RequestsCorrectUrlWithApiOptions()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableEventsClient(gitHubClient);

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

                client.GetAllForRepository("fake", "repo", options);

                gitHubClient.Connection.Received(1).Get <List <Activity> >(new Uri("repos/fake/repo/events", UriKind.Relative),
                                                                           Arg.Is <IDictionary <string, string> >(d => d.Count == 2), null);
            }
Beispiel #6
0
            public async Task ReturnsRepositoryEvents()
            {
                var repositoryEvents = await _eventsClient.GetAllForRepository(owner, name).ToList();

                Assert.NotEmpty(repositoryEvents);
            }