public void GetsStarsForCurrent() { var connection = Substitute.For<IConnection>(); var gitHubClient = Substitute.For<IGitHubClient>(); gitHubClient.Connection.Returns(connection); var client = new ObservableStarredClient(gitHubClient); client.GetAllForCurrent(); connection.Received().Get<List<Repository>>(ApiUrls.Starred(), null, null); }
public void RequestsCorrectUrlParametrizedWithApiOptions() { 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.GetAllForCurrent(request, options); connection.Received().Get<List<Repository>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 4 && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1"), null); }
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 RequestsCorrectUrl() { 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.GetAllForCurrent(); connection.Received().Get<List<Repository>>(endpoint, Args.EmptyDictionary, null); }