public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await client.Get(1, 42); connection.Received().Get<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/42")); }
public async Task EnsuresNonNullArguments() { var client = new PullRequestsClient(Substitute.For<IApiConnection>()); await AssertEx.Throws<ArgumentNullException>(() => client.Get(null, "name", 1)); await AssertEx.Throws<ArgumentNullException>(() => client.Get("owner", null, 1)); await AssertEx.Throws<ArgumentException>(() => client.Get(null, "", 1)); await AssertEx.Throws<ArgumentException>(() => client.Get("", null, 1)); }
public void RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); client.Get("fake", "repo", 42); connection.Received().Get<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42")); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.Commits("fake", "repo", 42); connection.Received() .GetAll <PullRequestCommit>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/commits")); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.Files(1, 42); connection.Received() .GetAll <PullRequestFile>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls/42/files")); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.GetAllForRepository("fake", "repo"); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Any <Dictionary <string, string> >(), Args.ApiOptions); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.GetAllForRepository(1); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await client.GetForRepository("fake", "repo"); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Any<Dictionary<string, string>>()); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await client.GetAllForRepository(1); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"), Arg.Any<Dictionary<string, string>>(), Args.ApiOptions); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); client.Get("fake", "repo", 42); connection.Received().Get <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls/42"), null); }
public void PostsToCorrectUrl() { var newPullRequest = new NewPullRequest("some title", "branch:name", "branch:name"); var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); client.Create("fake", "repo", newPullRequest); connection.Received().Post <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls"), newPullRequest); }
public void PostsToCorrectUrl() { var pullRequestUpdate = new PullRequestUpdate(); var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); client.Update("fake", "repo", 42, pullRequestUpdate); connection.Received().Patch <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls/42"), pullRequestUpdate); }
public void PutsToCorrectUrl() { var mergePullRequest = new MergePullRequest("fake commit message"); var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); client.Merge("fake", "repo", 42, mergePullRequest); connection.Received().Put <PullRequestMerge>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/merge"), mergePullRequest); }
public async Task PostsToCorrectUrlWithRepositoryId() { var pullRequestUpdate = new PullRequestUpdate(); var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.Update(1, 42, pullRequestUpdate); connection.Received().Patch <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls/42"), pullRequestUpdate, "application/vnd.github.shadow-cat-preview+json"); }
public async Task PostsToCorrectUrlWithRepositoryId() { var newPullRequest = new NewPullRequest("some title", "branch:name", "branch:name"); var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.Create(1, newPullRequest); connection.Received().Post <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls"), newPullRequest, "application/vnd.github.shadow-cat-preview+json"); }
public void PostsToCorrectUrl() { var newPullRequest = new NewPullRequest("some title", "branch:name", "branch:name"); var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); client.Create("fake", "repo", newPullRequest); connection.Received().Post<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), newPullRequest); }
public async Task EnsuresNonNullArguments() { var client = new PullRequestsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Get(null, "name", 1)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Get("owner", null, 1)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Get(null, "", 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.Get("", null, 1)); }
public void SetUp() { _restClient = MockRepository.GenerateMock <IBitbucketRestClient>(); var connection = new Connection( new Uri("http://url.com"), new Uri("http://api.url.com"), new Credentials("mistyku", "Password") ); _sut = new PullRequestsClient(_restClient, connection); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); AssertEx.Throws <ArgumentNullException>(async() => await client.Merge(null, "name", 42, new MergePullRequest("message"))); AssertEx.Throws <ArgumentException>(async() => await client.Merge("owner", null, 42, new MergePullRequest("message"))); AssertEx.Throws <ArgumentNullException>(async() => await client.Merge("owner", "name", 42, null)); }
public async Task EnsuresNonNullArguments() { var client = new PullRequestsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name", new PullRequestRequest())); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null, new PullRequestRequest())); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (PullRequestRequest)null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name", new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null, new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new PullRequestRequest(), null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, (PullRequestRequest)null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, new PullRequestRequest(), null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name", new PullRequestRequest())); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "", new PullRequestRequest())); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name", new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "", new PullRequestRequest(), ApiOptions.None)); }
public void PutsToCorrectUrl() { var mergePullRequest = new MergePullRequest { CommitMessage = "fake commit message" }; var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); client.Merge("fake", "repo", 42, mergePullRequest); connection.Received().Put <PullRequestMerge>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/merge"), mergePullRequest, null, "application/vnd.github.polaris-preview+json"); }
public void RequestsCorrectUrlWithRepositoryId() { var conn = Substitute.For <IConnection>(); var connection = Substitute.For <IApiConnection>(); connection.Connection.Returns(conn); var client = new PullRequestsClient(connection); client.Merged(1, 42); conn.Received().Get <object>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls/42/merge"), null, null); }
public void PutsToCorrectUrlWithRepositoryId() { var mergePullRequest = new MergePullRequest { CommitMessage = "fake commit message" }; var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); client.Merge(1, 42, mergePullRequest); connection.Received() .Put <PullRequestMerge>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls/42/merge"), mergePullRequest); }
public void RequestsCorrectUrl() { var conn = Substitute.For <IConnection>(); var connection = Substitute.For <IApiConnection>(); connection.Connection.Returns(conn); var client = new PullRequestsClient(connection); client.Merged("fake", "repo", 42); conn.Received().GetAsync <object>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/merge"), null, null); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Files(null, "name", 1)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Files("owner", null, 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.Files("", "name", 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.Files("owner", "", 1)); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await AssertEx.Throws <ArgumentNullException>(async() => await client.Merged(null, "name", 1)); await AssertEx.Throws <ArgumentNullException>(async() => await client.Merged("owner", null, 1)); await AssertEx.Throws <ArgumentException>(async() => await client.Merged(null, "", 1)); await AssertEx.Throws <ArgumentException>(async() => await client.Merged("", null, 1)); }
public void SendsAppropriateParameters() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); client.GetForRepository("fake", "repo", new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch" }); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["head"] == "user:ref-head" && d["state"] == "open" && d["base"] == "fake_base_branch")); }
public async Task SendsAppropriateParametersWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await client.GetAllForRepository(1, new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch" }); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls"), Arg.Is <Dictionary <string, string> >(d => d.Count == 5 && d["head"] == "user:ref-head" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions); }
public void SendsAppropriateParameters() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); client.GetForRepository("fake", "repo", new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch" }); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Is <Dictionary <string, string> >(d => d.Count == 3 && d["head"] == "user:ref-head" && d["state"] == "open" && d["base"] == "fake_base_branch")); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); AssertEx.Throws <ArgumentNullException>(async() => await client.Create(null, "name", new NewPullRequest("title", "ref", "ref2"))); AssertEx.Throws <ArgumentException>(async() => await client.Create("", "name", new NewPullRequest("title", "ref", "ref2"))); AssertEx.Throws <ArgumentNullException>(async() => await client.Create("owner", null, new NewPullRequest("title", "ref", "ref2"))); AssertEx.Throws <ArgumentException>(async() => await client.Create("owner", "", new NewPullRequest("title", "ref", "ref2"))); AssertEx.Throws <ArgumentNullException>(async() => await client.Create("owner", "name", null)); }
public BitbucketClient( Connection apiConnection, IProxyResolver proxyResolver ) { ApiConnection = apiConnection; _client = new BitbucketRestClient(apiConnection) { ProxyResolver = proxyResolver }; RepositoriesClient = new RepositoriesClient(_client, ApiConnection); UserClient = new UserClient(_client, ApiConnection); PullRequestsClient = new PullRequestsClient(_client, ApiConnection); TeamsClient = new TeamsClient(_client, ApiConnection); }
public async Task ShouldUpdateExistsingPullRequestsAndNotCreateDuplicates() { var activePullRequests = GeneratePullRequests(5); SetupMultiple(VerifyPredicateForActivePullRequests, activePullRequests); SetupCreateOrUpdate <PullRequest>(); SetupPullRequestsFetch(activePullRequests, Enumerable.Empty <PullRequest>()); SetupIterations(); SetupThreads(); await _handler.Handle(new Vsts.Commands.UpdateActivePullRequests()); RepositoryMock.Verify(r => r.GetAsync <PullRequest>(p => p.State == PullRequestState.Active), Times.Once()); VstsClientFactory.Verify(); PullRequestsClient.Verify(); }
public async Task RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForRepository("fake", "repo", options); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Any<Dictionary<string, string>>(), options); }
public BitbucketClient( Connection apiConnection, Connection internalConnection, Connection versionOneApiConnection, Connection webConnection) { ApiConnection = apiConnection; var client = new BitbucketRestClient(apiConnection); var internalClient = new BitbucketRestClient(internalConnection); var versionOneClient = new BitbucketRestClient(versionOneApiConnection); var webClient = new BitbucketRestClient(webConnection); RepositoriesClient = new RepositoriesClient(client, versionOneClient, ApiConnection); UserClient = new UserClient(client, ApiConnection); PullRequestsClient = new PullRequestsClient(client, internalClient, webClient, versionOneClient, ApiConnection); TeamsClient = new TeamsClient(client, ApiConnection); }
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForRepository(1, options); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls"), Arg.Any <Dictionary <string, string> >(), options); }
public async Task RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForRepository("fake", "repo", options); connection.Received().GetAll <PullRequest>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.shadow-cat-preview+json", options); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null, "name", new NewPullRequest("title", "ref", "ref2"))); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", null, new NewPullRequest("title", "ref", "ref2"))); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", "name", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.Create("", "name", new NewPullRequest("title", "ref", "ref2"))); await Assert.ThrowsAsync <ArgumentException>(() => client.Create("owner", "", new NewPullRequest("title", "ref", "ref2"))); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For <IApiConnection>(); var client = new PullRequestsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Merge(null, "name", 42, new MergePullRequest { CommitMessage = "message" })); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Merge("owner", null, 42, new MergePullRequest { CommitMessage = "message" })); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Merge("owner", "name", 42, null)); }
public void PostsToCorrectUrl() { var pullRequestUpdate = new PullRequestUpdate(); var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); client.Update("fake", "repo", 42, pullRequestUpdate); connection.Received().Patch<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42"), pullRequestUpdate); }
public async Task PostsToCorrectUrlWithRepositoryId() { var newPullRequest = new NewPullRequest("some title", "branch:name", "branch:name"); var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await client.Create(1, newPullRequest); connection.Received().Post<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"), newPullRequest); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Files(null, "name", 1)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Files("owner", null, 1)); await Assert.ThrowsAsync<ArgumentException>(() => client.Files("", "name", 1)); await Assert.ThrowsAsync<ArgumentException>(() => client.Files("owner", "", 1)); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Merge(null, "name", 42, new MergePullRequest { CommitMessage = "message" })); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Merge("owner", null, 42, new MergePullRequest { CommitMessage = "message" })); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Merge("owner", "name", 42, null)); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await AssertEx.Throws<ArgumentNullException>(() => client.Create(null, "name", new NewPullRequest("title", "ref", "ref2"))); await AssertEx.Throws<ArgumentException>(() => client.Create("", "name", new NewPullRequest("title", "ref", "ref2"))); await AssertEx.Throws<ArgumentNullException>(() => client.Create("owner", null, new NewPullRequest("title", "ref", "ref2"))); await AssertEx.Throws<ArgumentException>(() => client.Create("owner", "", new NewPullRequest("title", "ref", "ref2"))); await AssertEx.Throws<ArgumentNullException>(() => client.Create("owner", "name", null)); }
public async Task PostsToCorrectUrlWithRepositoryId() { var pullRequestUpdate = new PullRequestUpdate(); var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await client.Update(1, 42, pullRequestUpdate); connection.Received().Patch<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/42"), pullRequestUpdate); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); AssertEx.Throws<ArgumentNullException>(async () => await client.Merge(null, "name", 42, new MergePullRequest("message"))); AssertEx.Throws<ArgumentException>(async () => await client.Merge("owner", null, 42, new MergePullRequest("message"))); AssertEx.Throws<ArgumentNullException>(async () => await client.Merge("owner", "name", 42, null)); }
public void PutsToCorrectUrl() { var mergePullRequest = new MergePullRequest { CommitMessage = "fake commit message" }; var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); client.Merge("fake", "repo", 42, mergePullRequest); connection.Received().Put<PullRequestMerge>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/merge"), mergePullRequest,null, "application/vnd.github.polaris-preview+json"); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await client.Files("fake", "repo", 42); connection.Received() .GetAll<PullRequestFile>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/files")); }
public void RequestsCorrectUrl() { var conn = Substitute.For<IConnection>(); var connection = Substitute.For<IApiConnection>(); connection.Connection.Returns(conn); var client = new PullRequestsClient(connection); client.Merged("fake", "repo", 42); conn.Received().Get<object>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/merge"), null, null); }
public async Task EnsuresNonNullArguments() { var client = new PullRequestsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new PullRequestRequest())); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new PullRequestRequest())); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (PullRequestRequest)null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new PullRequestRequest(), null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", new PullRequestRequest())); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new PullRequestRequest())); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", new PullRequestRequest(), ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new PullRequestRequest(), ApiOptions.None)); }
public async Task SendsAppropriateParametersWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForRepository("fake", "repo", new PullRequestRequest { Head = "user:ref-head", Base = "fake_base_branch" }, options); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), Arg.Is<Dictionary<string, string>>(d => d.Count == 5 && d["head"] == "user:ref-head" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" && d["direction"] == "desc"), options); }
public void PutsToCorrectUrl() { var mergePullRequest = new MergePullRequest("fake commit message"); var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); client.Merge("fake", "repo", 42, mergePullRequest); connection.Received().Put<PullRequestMerge>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/merge"), mergePullRequest); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For<IApiConnection>(); var client = new PullRequestsClient(connection); await AssertEx.Throws<ArgumentNullException>(async () => await client.Merged(null, "name", 1)); await AssertEx.Throws<ArgumentNullException>(async () => await client.Merged("owner", null, 1)); await AssertEx.Throws<ArgumentException>(async () => await client.Merged(null, "", 1)); await AssertEx.Throws<ArgumentException>(async () => await client.Merged("", null, 1)); }