public async Task EnsuresNonNullArguments() { var client = new ObservableNotificationsClient(Substitute.For<IGitHubClient>()); 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", (ApiOptions)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new NotificationsRequest())); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new NotificationsRequest())); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (NotificationsRequest)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new NotificationsRequest(), ApiOptions.None)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new NotificationsRequest(), ApiOptions.None)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new NotificationsRequest(), null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (NotificationsRequest)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, new NotificationsRequest(), 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)); Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", new NotificationsRequest())); Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", new NotificationsRequest())); Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", new NotificationsRequest(), ApiOptions.None)); Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", new NotificationsRequest(), ApiOptions.None)); }
public void RequestsCorrectUrlNotificationRequestWithApiOptionsWithRepositoryId() { var endpoint = new Uri("repositories/1/notifications", UriKind.Relative); var connection = Substitute.For<IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableNotificationsClient(gitHubClient); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAllForRepository(1, notificationsRequest, options); connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>( d => d.Count == 4 && d["all"] == "true" && d["participating"] == "false" && d["page"] == "1" && d["per_page"] == "1"), null); }
public void RequestsCorrectUrlWithApiOptionsWithRepositoryId() { var endpoint = new Uri("repositories/1/notifications", UriKind.Relative); var connection = Substitute.For<IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableNotificationsClient(gitHubClient); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAllForRepository(1, options); connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); }
public void RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For<IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableNotificationsClient(gitHubClient); var notificationsRequest = new NotificationsRequest { All = true }; client.GetAllForRepository("banana", "split", notificationsRequest); connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>( d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), null); }
public void RequestsCorrectUrlWithRepositoryId() { var endpoint = new Uri("repositories/1/notifications", UriKind.Relative); var connection = Substitute.For<IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableNotificationsClient(gitHubClient); client.GetAllForRepository(1); connection.Received().Get<List<Notification>>(endpoint, Args.EmptyDictionary, null); }