public void RequestsCorrectUrlWithTimestampsParametrizedWithApiOptions() { var endpoint = new Uri("user/starred", UriKind.Relative); var connection = Substitute.For<IConnection>(); var gitHubClient = Substitute.For<IGitHubClient>(); gitHubClient.Connection.Returns(connection); var client = new ObservableStarredClient(gitHubClient); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; var request = new StarredRequest { SortDirection = SortDirection.Ascending }; client.GetAllForCurrentWithTimestamps(request, options); connection.Received().Get<List<RepositoryStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 4 && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1"), "application/vnd.github.v3.star+json"); }
public void EnsuresNonNullArguments() { var client = new ObservableStarredClient(Substitute.For<IGitHubClient>()); Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent((ApiOptions)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent((StarredRequest)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps((ApiOptions)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps((StarredRequest)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent(null, new ApiOptions())); Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent(new StarredRequest(), null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps(null, new ApiOptions())); Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps(new StarredRequest(), null)); }
public void RequestsCorrectUrlWithTimestamps() { var endpoint = new Uri("user/starred", UriKind.Relative); var connection = Substitute.For<IConnection>(); var gitHubClient = Substitute.For<IGitHubClient>(); gitHubClient.Connection.Returns(connection); var client = new ObservableStarredClient(gitHubClient); client.GetAllForCurrentWithTimestamps(); connection.Received().Get<List<RepositoryStar>>(endpoint, Args.EmptyDictionary, "application/vnd.github.v3.star+json"); }