public async Task EnsuresNonNullArguments() { var client = new WatchedClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForUser(null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForUser(null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForUser("user", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForUser("")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForUser("", ApiOptions.None)); }
public void RequestsCorrectUrl() { var endpoint = new Uri("users/banana/subscriptions", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new WatchedClient(connection); client.GetAllForUser("banana"); connection.Received().GetAll<Repository>(endpoint); }
public async Task RequestsCorrectUrlWithApiOptions() { var endpoint = new Uri("users/banana/subscriptions", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new WatchedClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForUser("banana", options); connection.Received().GetAll <Repository>(endpoint, options); }
public async Task EnsuresNonNullArguments() { var client = new WatchedClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser(null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser(null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser("user", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser("")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser("", ApiOptions.None)); }
public void RequestsCorrectUrlWithApiOptions() { var endpoint = new Uri("users/banana/subscriptions", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new WatchedClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; client.GetAllForUser("banana", options); connection.Received().GetAll<Repository>(endpoint, options); }