diff --git a/.vscode/launch.json b/.vscode/launch.json index ed3c564026..dd7b108d27 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -23,6 +23,17 @@ "console": "internalConsole", "stopAtEntry": false }, + { + "name": "Run integration tests", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/Octokit.Tests.Integration/bin/Debug/netcoreapp3.1/Octokit.Tests.Integration.dll", + "args": [], + "cwd": "${workspaceFolder}/Octokit.Tests.Integration", + "console": "internalConsole", + "stopAtEntry": false + }, { "name": "Attach to process", "type": "coreclr", diff --git a/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs index ec7e43f40f..ec816645e8 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs @@ -143,6 +143,6 @@ public IObservable Update(string org, OrganizationUpdate updateReq return _client.Update(org, updateRequest).ToObservable(); } - + } } diff --git a/Octokit.Tests.Integration/Clients/OrganizationHooksClientTests.cs b/Octokit.Tests.Integration/Clients/OrganizationHooksClientTests.cs index a70b089934..26a6bd6cfe 100644 --- a/Octokit.Tests.Integration/Clients/OrganizationHooksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/OrganizationHooksClientTests.cs @@ -23,7 +23,7 @@ public async Task ReturnsAllHooksFromOrganization() { var github = Helper.GetAuthenticatedClient(); - var hooks = await github.Organization.Hook.GetAll( _fixture.org); + var hooks = await github.Organization.Hook.GetAll(_fixture.org); Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count); @@ -148,24 +148,23 @@ public async Task CreateAWebHookForTestOrganization() Assert.Equal(new[] { "push" }.ToList(), hook.Events.ToList()); Assert.Equal(baseHookUrl, hook.Url); Assert.Equal(baseHookUrl + "/pings", hook.PingUrl); - Assert.NotNull(hook.CreatedAt); - Assert.NotNull(hook.UpdatedAt); + Assert.NotEqual(default, hook.CreatedAt); + Assert.NotEqual(default, hook.UpdatedAt); Assert.Equal(webHookConfig.Keys, hook.Config.Keys); - //Assert.Equal(webHookConfig.Values, hook.Config.Values); - Assert.Equal(false, hook.Active); + Assert.False(hook.Active); } Dictionary CreateExpectedConfigDictionary(Dictionary config, string url, OrgWebHookContentType contentType) { return new Dictionary { - + }.Union(config).ToDictionary(k => k.Key, v => v.Value); } string CreateExpectedBaseHookUrl(string org, int id) { - return "https://api.github.com/orgs/" + org+ "/hooks/" + id; + return "https://api.github.com/orgs/" + org + "/hooks/" + id; } } @@ -189,7 +188,7 @@ public async Task EditHookTest() Events = new[] { "pull_request" } }; - var actualHook = await github.Organization.Hook.Edit( _fixture.org, _fixture.ExpectedHook.Id, editOrganizationHook); + var actualHook = await github.Organization.Hook.Edit(_fixture.org, _fixture.ExpectedHook.Id, editOrganizationHook); var expectedConfig = new Dictionary { { "content_type", "json" }, { "url", "http://test.com/example" } }; Assert.Equal(new[] { "commit_comment", "pull_request" }.ToList(), actualHook.Events.ToList()); @@ -213,7 +212,7 @@ public async Task PingACreatedHook() { var github = Helper.GetAuthenticatedClient(); - await github.Organization.Hook.Ping( _fixture.org, _fixture.ExpectedHook.Id); + await github.Organization.Hook.Ping(_fixture.org, _fixture.ExpectedHook.Id); } } @@ -233,7 +232,7 @@ public async Task DeleteCreatedWebHook() var github = Helper.GetAuthenticatedClient(); await github.Organization.Hook.Delete(_fixture.org, _fixture.ExpectedHook.Id); - var hooks = await github.Organization.Hook.GetAll( _fixture.org); + var hooks = await github.Organization.Hook.GetAll(_fixture.org); Assert.Empty(hooks); } diff --git a/Octokit.Tests.Integration/fixtures/OrganizationsHooksFixture.cs b/Octokit.Tests.Integration/fixtures/OrganizationsHooksFixture.cs index d708b508f7..8fefa8d1f2 100644 --- a/Octokit.Tests.Integration/fixtures/OrganizationsHooksFixture.cs +++ b/Octokit.Tests.Integration/fixtures/OrganizationsHooksFixture.cs @@ -32,7 +32,7 @@ public OrganizationsHooksFixture() public void Dispose() { - _github.Organization.Hook.Delete(_organizationFixture,_hook.Id); + _github.Organization.Hook.Delete(_organizationFixture, _hook.Id); } static OrganizationHook CreateHook(IGitHubClient github, string orgFixture, string hookName, string eventName) diff --git a/Octokit.Tests/Clients/OrganizationHooksClientTest.cs b/Octokit.Tests/Clients/OrganizationHooksClientTest.cs index 7a06b95d9b..577fee7860 100644 --- a/Octokit.Tests/Clients/OrganizationHooksClientTest.cs +++ b/Octokit.Tests/Clients/OrganizationHooksClientTest.cs @@ -94,7 +94,7 @@ public async Task EnsuresNonEmptyArguments() { var client = new OrganizationsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Hook.Get("",123)); + await Assert.ThrowsAsync(() => client.Hook.Get("", 123)); } } @@ -162,8 +162,8 @@ public async Task EnsuresNonNullArguments() { var client = new OrganizationsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Hook.Edit( null, 12345678, new EditOrganizationHook())); - await Assert.ThrowsAsync(() => client.Hook.Edit( "name", 12345678, null)); + await Assert.ThrowsAsync(() => client.Hook.Edit(null, 12345678, new EditOrganizationHook())); + await Assert.ThrowsAsync(() => client.Hook.Edit("name", 12345678, null)); } [Fact] diff --git a/Octokit.Tests/Models/NewOrganizationWebHookTests.cs b/Octokit.Tests/Models/NewOrganizationWebHookTests.cs index ae38c6709b..55c93e5268 100644 --- a/Octokit.Tests/Models/NewOrganizationWebHookTests.cs +++ b/Octokit.Tests/Models/NewOrganizationWebHookTests.cs @@ -11,23 +11,23 @@ public class TheCtor public void UsesDefaultValuesForDefaultConfig() { var create = new NewOrganizationWebHook("windowsazure", new Dictionary(), "http://test.com/example"); - Assert.Equal(create.Url, "http://test.com/example"); - Assert.Equal(create.ContentType, OrgWebHookContentType.Form); + Assert.Equal("http://test.com/example", create.Url); + Assert.Equal(OrgWebHookContentType.Form, create.ContentType); Assert.Empty(create.Secret); Assert.False(create.InsecureSsl); var request = create.ToRequest(); - Assert.Equal(request.Config.Count, 4); + Assert.Equal(4, request.Config.Count); Assert.True(request.Config.ContainsKey("url")); Assert.True(request.Config.ContainsKey("content_type")); Assert.True(request.Config.ContainsKey("secret")); Assert.True(request.Config.ContainsKey("insecure_ssl")); - Assert.Equal(request.Config["url"], "http://test.com/example"); + Assert.Equal("http://test.com/example", request.Config["url"]); Assert.Equal(request.Config["content_type"], OrgWebHookContentType.Form.ToParameter()); - Assert.Equal(request.Config["secret"], ""); - Assert.Equal(request.Config["insecure_ssl"], "False"); + Assert.Equal("", request.Config["secret"]); + Assert.Equal("False", request.Config["insecure_ssl"]); } [Fact] @@ -47,24 +47,24 @@ public void CombinesUserSpecifiedContentTypeWithConfig() InsecureSsl = true }; - Assert.Equal(create.Url, "http://test.com/example"); - Assert.Equal(create.ContentType, OrgWebHookContentType.Json); + Assert.Equal("http://test.com/example", create.Url); + Assert.Equal(OrgWebHookContentType.Json, create.ContentType); Assert.Empty(create.Secret); Assert.True(create.InsecureSsl); var request = create.ToRequest(); - Assert.Equal(request.Config.Count, 7); + Assert.Equal(7, request.Config.Count); Assert.True(request.Config.ContainsKey("url")); Assert.True(request.Config.ContainsKey("content_type")); Assert.True(request.Config.ContainsKey("secret")); Assert.True(request.Config.ContainsKey("insecure_ssl")); - Assert.Equal(request.Config["url"], "http://test.com/example"); + Assert.Equal("http://test.com/example", request.Config["url"]); Assert.Equal(request.Config["content_type"], OrgWebHookContentType.Json.ToParameter()); - Assert.Equal(request.Config["secret"], ""); - Assert.Equal(request.Config["insecure_ssl"], true.ToString()); + Assert.Equal("", request.Config["secret"]); + Assert.Equal("True", request.Config["insecure_ssl"]); Assert.True(request.Config.ContainsKey("hostname")); Assert.Equal(request.Config["hostname"], config["hostname"]); @@ -110,8 +110,8 @@ public void ShouldNotContainDuplicateConfigEntriesOnSubsequentRequests() var request = create.ToRequest(); var requestRepeated = create.ToRequest(); - Assert.Equal(request.Config.Count, 4); - Assert.Equal(requestRepeated.Config.Count, 4); + Assert.Equal(4, request.Config.Count); + Assert.Equal(4, requestRepeated.Config.Count); } [Fact] @@ -131,8 +131,8 @@ public void ShouldNotContainDuplicateConfigEntriesOnSubsequentRequestsWithCustom var requestRepeated = create.ToRequest(); //This is not 8, because `url` used in config, is already part of the base config - Assert.Equal(request.Config.Count, 7); - Assert.Equal(requestRepeated.Config.Count, 7); + Assert.Equal(7, request.Config.Count); + Assert.Equal(7, requestRepeated.Config.Count); } [Fact] @@ -147,10 +147,10 @@ public void PropertiesShouldTakePrecedenceOverConfigPassedIn() var request = create.ToRequest(); - Assert.Equal(request.Config["url"], "http://test.com/example"); + Assert.Equal("http://test.com/example", request.Config["url"]); var subsequentRequest = create.ToRequest(); - Assert.Equal(subsequentRequest.Config["url"], "http://test.com/example"); + Assert.Equal("http://test.com/example", subsequentRequest.Config["url"]); } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index aa52d18df9..be3a06c289 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -1016,7 +1016,7 @@ public static Uri OrganizationHookPing(string org, int hookId) { return "orgs/{0}/hooks/{1}/pings".FormatUri(org, hookId); } - + /// /// Returns the that lists the commit statuses for the specified reference. ///