public async Task EnsuresNonNullArguments() { var client = new WatchedClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.WatchRepo(null, "name", new NewSubscription())); await Assert.ThrowsAsync <ArgumentNullException>(() => client.WatchRepo("owner", null, new NewSubscription())); await Assert.ThrowsAsync <ArgumentNullException>(() => client.WatchRepo("owner", "name", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.WatchRepo("", "name", new NewSubscription())); await Assert.ThrowsAsync <ArgumentException>(() => client.WatchRepo("owner", "", new NewSubscription())); }
public async Task <Subscription> WatchRepository(long repositoryId, NewSubscription subscription, GitHubClient authorizedGitHubClient) { if (_watchedClient == null) { _watchedClient = new WatchedClient(new ApiConnection(authorizedGitHubClient.Connection)); } return(await _watchedClient.WatchRepo(repositoryId, subscription)); }
public void RequestsCorrectUrl() { var endpoint = new Uri("repos/fight/club/subscription", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new WatchedClient(connection); var newSubscription = new NewSubscription(); client.WatchRepo("fight", "club", newSubscription); connection.Received().Put<Subscription>(endpoint, newSubscription); }
public void RequestsCorrectUrlWithRepositoryId() { var endpoint = new Uri("repositories/1/subscription", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new WatchedClient(connection); var newSubscription = new NewSubscription(); client.WatchRepo(1, newSubscription); connection.Received().Put <Subscription>(endpoint, newSubscription); }