public void RequestCorrectUrlWithRequestParameter() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableProjectsClient(gitHubClient); client.GetAllForOrganization("org", new ProjectRequest(ItemStateFilter.Closed)); connection.Received().Get <List <Project> >( Arg.Is <Uri>(u => u.ToString() == "orgs/org/projects"), Arg.Is <Dictionary <string, string> >(d => d.ContainsKey("state")), "application/vnd.github.inertia-preview+json"); }
public void RequestCorrectUrl() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableProjectsClient(gitHubClient); client.GetAllForOrganization("org"); connection.Received().Get <List <Project> >( Arg.Is <Uri>(u => u.ToString() == "orgs/org/projects"), Args.EmptyDictionary, "application/vnd.github.inertia-preview+json"); }
public async Task EnsureNonNullOrEmptyArguments() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableProjectsClient(gitHubClient); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization(null).ToTask()); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForOrganization("").ToTask()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization(null, ApiOptions.None).ToTask()); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForOrganization("", ApiOptions.None).ToTask()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization("org", (ApiOptions)null).ToTask()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization(null, new ProjectRequest(ItemStateFilter.All)).ToTask()); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForOrganization("", new ProjectRequest(ItemStateFilter.All)).ToTask()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization("org", (ProjectRequest)null).ToTask()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization(null, new ProjectRequest(ItemStateFilter.All), ApiOptions.None).ToTask()); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForOrganization("", new ProjectRequest(ItemStateFilter.All), ApiOptions.None).ToTask()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization("org", new ProjectRequest(ItemStateFilter.All), null).ToTask()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization("org", null, ApiOptions.None).ToTask()); }