public void RequestsCorrectUrlWithTimestampsParametrized() { var endpoint = new Uri("users/banana/starred", UriKind.Relative); var connection = Substitute.For <IConnection>(); var gitHubClient = Substitute.For <IGitHubClient>(); gitHubClient.Connection.Returns(connection); var client = new ObservableStarredClient(gitHubClient); var starredRequest = new StarredRequest { SortDirection = SortDirection.Ascending }; client.GetAllForUserWithTimestamps("banana", starredRequest); connection.Received().Get <List <RepositoryStar> >(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && d["direction"] == "asc"), "application/vnd.github.v3.star+json"); }
public void RequestsCorrectUrlWithTimestampsWithApiOptions() { var endpoint = new Uri("users/banana/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 }; client.GetAllForUserWithTimestamps("banana", options); connection.Received().Get <List <RepositoryStar> >(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && 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.GetAllForUser(null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUser(null, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUser("banana", (ApiOptions)null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUser(null, new StarredRequest())); Assert.Throws <ArgumentNullException>(() => client.GetAllForUser("banana", (StarredRequest)null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUser(null, new StarredRequest(), ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUser("banana", null, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUser("banana", new StarredRequest(), null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", (ApiOptions)null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null, new StarredRequest())); Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", (StarredRequest)null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null, new StarredRequest(), ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", null, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", new StarredRequest(), null)); Assert.Throws <ArgumentException>(() => client.GetAllForUser("")); Assert.Throws <ArgumentException>(() => client.GetAllForUser("", ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllForUser("", new StarredRequest(), ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllForUserWithTimestamps("")); Assert.Throws <ArgumentException>(() => client.GetAllForUserWithTimestamps("", ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllForUserWithTimestamps("", new StarredRequest(), ApiOptions.None)); }