public void EnsuresNonNullArguments() { var client = new ObservableWatchedClient(Substitute.For <IGitHubClient>()); Assert.Throws <ArgumentNullException>(() => client.GetAllWatchers(null, "name")); Assert.Throws <ArgumentNullException>(() => client.GetAllWatchers("owner", null)); Assert.Throws <ArgumentNullException>(() => client.GetAllWatchers(null, "name", ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllWatchers("owner", null, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllWatchers("owner", "name", null)); Assert.Throws <ArgumentNullException>(() => client.GetAllWatchers(1, null)); Assert.Throws <ArgumentException>(() => client.GetAllWatchers("", "name")); Assert.Throws <ArgumentException>(() => client.GetAllWatchers("owner", "")); Assert.Throws <ArgumentException>(() => client.GetAllWatchers("", "name", ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllWatchers("owner", "", ApiOptions.None)); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IConnection>(); var gitHubClient = Substitute.For <IGitHubClient>(); gitHubClient.Connection.Returns(connection); var client = new ObservableWatchedClient(gitHubClient); client.GetAllWatchers("jugglingnutcase", "katiejamie"); connection.Received().Get <List <User> >(ApiUrls.Watchers("jugglingnutcase", "katiejamie"), Args.EmptyDictionary, null); }
public void RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IConnection>(); var gitHubClient = Substitute.For <IGitHubClient>(); gitHubClient.Connection.Returns(connection); var client = new ObservableWatchedClient(gitHubClient); client.GetAllWatchers(1); connection.Received().Get <List <User> >(ApiUrls.Watchers(1), Args.EmptyDictionary, null); }
public void RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For <IConnection>(); var gitHubClient = Substitute.For <IGitHubClient>(); gitHubClient.Connection.Returns(connection); var client = new ObservableWatchedClient(gitHubClient); ApiOptions options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; client.GetAllWatchers("jugglingnutcase", "katiejamie", options); connection.Received().Get <List <User> >(ApiUrls.Watchers("jugglingnutcase", "katiejamie"), Arg.Is <Dictionary <string, string> >(d => d.Count == 2), null); }