x), hook.Config.Keys.OrderBy(x => x));
Assert.Equal(webHookConfig.Values.OrderBy(x => x), hook.Config.Values.OrderBy(x => x));
- Assert.Equal(false, hook.Active);
+ Assert.False(hook.Active);
}
[IntegrationTest]
@@ -277,11 +277,11 @@ public async Task CreateAWebHookForTestRepositoryWithRepositoryId()
Assert.Equal(baseHookUrl, hook.Url);
Assert.Equal(baseHookUrl + "/test", hook.TestUrl);
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.OrderBy(x => x), hook.Config.Keys.OrderBy(x => x));
Assert.Equal(webHookConfig.Values.OrderBy(x => x), hook.Config.Values.OrderBy(x => x));
- Assert.Equal(false, hook.Active);
+ Assert.False(hook.Active);
}
Dictionary
CreateExpectedConfigDictionary(Dictionary config, string url, WebHookContentType contentType, string secret)
diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs
index a4104878cb..616b04ae06 100644
--- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs
@@ -32,7 +32,7 @@ public async Task SearchForForkedRepositories()
};
var repos = await _gitHubClient.Search.SearchRepo(request);
- Assert.True(repos.Items.Any(x => x.Fork));
+ Assert.Contains(repos.Items, x => x.Fork);
}
[IntegrationTest]
@@ -112,7 +112,7 @@ public async Task SearchForLanguageInCode()
foreach (var code in searchResults.Items)
{
- Assert.True(code.Name.EndsWith(".cs"));
+ Assert.EndsWith(".cs", code.Name);
}
}
diff --git a/Octokit.Tests.Integration/Clients/TagsClientTests.cs b/Octokit.Tests.Integration/Clients/TagsClientTests.cs
index a74320cd84..3fc83ee5f6 100644
--- a/Octokit.Tests.Integration/Clients/TagsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/TagsClientTests.cs
@@ -36,8 +36,8 @@ public async Task CreatesTagForRepository()
var tag = await fixture.Create(context.Repository.Id, newTag);
- Assert.Equal(tag.Object.Type, TaggedType.Blob);
- Assert.Equal(tag.Message, "Hello");
+ Assert.Equal(TaggedType.Blob, tag.Object.Type);
+ Assert.Equal("Hello", tag.Message);
Assert.Equal(tag.Object.Sha, sha);
}
@@ -48,8 +48,8 @@ public async Task CreatesTagForRepositoryWithRepositoryId()
var tag = await fixture.Create(context.Repository.Id, newTag);
- Assert.Equal(tag.Object.Type, TaggedType.Blob);
- Assert.Equal(tag.Message, "Hello");
+ Assert.Equal(TaggedType.Blob, tag.Object.Type);
+ Assert.Equal("Hello", tag.Message);
Assert.Equal(tag.Object.Sha, sha);
}
}
@@ -86,8 +86,8 @@ public async Task CreatesTagForRepository()
var gitTag = await fixture.Get(context.RepositoryOwner, context.RepositoryName, tag.Sha);
Assert.NotNull(gitTag);
- Assert.Equal(gitTag.Object.Type, TaggedType.Blob);
- Assert.Equal(gitTag.Message, "Hello");
+ Assert.Equal(TaggedType.Blob, gitTag.Object.Type);
+ Assert.Equal("Hello", gitTag.Message);
Assert.Equal(gitTag.Object.Sha, sha);
}
@@ -103,8 +103,8 @@ public async Task CreatesTagForRepositoryWithRepositoryId()
var gitTag = await github.Git.Tag.Get(context.Repository.Id, tag.Sha);
Assert.NotNull(gitTag);
- Assert.Equal(gitTag.Object.Type, TaggedType.Blob);
- Assert.Equal(gitTag.Message, "Hello");
+ Assert.Equal(TaggedType.Blob, gitTag.Object.Type);
+ Assert.Equal("Hello", gitTag.Message);
Assert.Equal(gitTag.Object.Sha, sha);
}
@@ -122,7 +122,7 @@ public async Task DeserializeTagSignatureVerification()
Assert.NotNull(gitTag);
Assert.False(gitTag.Verification.Verified);
- Assert.Equal(gitTag.Verification.Reason, VerificationReason.Unsigned);
+ Assert.Equal(VerificationReason.Unsigned, gitTag.Verification.Reason);
Assert.Null(gitTag.Verification.Signature);
Assert.Null(gitTag.Verification.Payload);
}
diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
index bc6563ca6b..ec6252c0e4 100644
--- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
@@ -72,8 +72,8 @@ public async Task GetsAllChildTeams()
var teams = await _github.Organization.Team.GetAllChildTeams(parentTeamContext.TeamId);
Assert.Equal(2, teams.Count);
- Assert.True(teams.Any(x => x.Id == team1.Id));
- Assert.True(teams.Any(x => x.Id == team2.Id));
+ Assert.Contains(teams, x => x.Id == team1.Id);
+ Assert.Contains(teams, x => x.Id == team2.Id);
}
}
diff --git a/Octokit.Tests.Integration/Clients/UserGpgKeysClientTests.cs b/Octokit.Tests.Integration/Clients/UserGpgKeysClientTests.cs
index 18beafa68a..b0b270fc1d 100644
--- a/Octokit.Tests.Integration/Clients/UserGpgKeysClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/UserGpgKeysClientTests.cs
@@ -44,7 +44,7 @@ public async Task CanGetAllForCurrentUser()
Assert.NotEmpty(keys);
var first = keys[0];
- Assert.NotNull(first.Id);
+ Assert.NotEqual(default, first.Id);
Assert.NotNull(first.KeyId);
Assert.NotNull(first.PublicKey);
Assert.Null(first.PrimaryKeyId);
@@ -81,7 +81,7 @@ public async Task CanCreateAndDeleteKey()
// Verify key no longer exists
var keys = await github.User.GpgKey.GetAllForCurrent();
- Assert.False(keys.Any(k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey));
+ Assert.DoesNotContain(keys, k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey);
}
[IntegrationTest]
@@ -96,7 +96,7 @@ public async Task CanNotCreateSameKeyTwice()
await github.User.GpgKey.Delete(key.Id);
var keys = await github.User.GpgKey.GetAllForCurrent();
- Assert.False(keys.Any(k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey));
+ Assert.DoesNotContain(keys, k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey);
}
}
}
diff --git a/Octokit.Tests.Integration/Clients/UserKeysClientTests.cs b/Octokit.Tests.Integration/Clients/UserKeysClientTests.cs
index 4bf48d3a18..4ca95d49b0 100644
--- a/Octokit.Tests.Integration/Clients/UserKeysClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/UserKeysClientTests.cs
@@ -18,7 +18,7 @@ public async Task CanGetAllForCurrentUser()
Assert.NotEmpty(keys);
var first = keys[0];
- Assert.NotNull(first.Id);
+ Assert.NotEqual(default, first.Id);
Assert.NotNull(first.Key);
Assert.NotNull(first.Title);
Assert.NotNull(first.Url);
@@ -34,7 +34,7 @@ public async Task CanGetAllForGivenUser()
Assert.NotEmpty(keys);
var first = keys[0];
- Assert.NotNull(first.Id);
+ Assert.NotEqual(default, first.Id);
Assert.NotNull(first.Key);
Assert.Null(first.Title);
Assert.Null(first.Url);
@@ -75,7 +75,7 @@ public async Task CanCreateAndDeleteKey()
// Verify key no longer exists
var keys = await github.User.GitSshKey.GetAllForCurrent();
- Assert.False(keys.Any(k => k.Title == keyTitle && k.Key == keyData));
+ Assert.DoesNotContain(keys, k => k.Title == keyTitle && k.Key == keyData);
}
}
}
diff --git a/Octokit.Tests.Integration/EnterpriseHelper.cs b/Octokit.Tests.Integration/EnterpriseHelper.cs
index 6db9437991..bd9f5cde1e 100644
--- a/Octokit.Tests.Integration/EnterpriseHelper.cs
+++ b/Octokit.Tests.Integration/EnterpriseHelper.cs
@@ -69,7 +69,7 @@ public static class EnterpriseHelper
static EnterpriseHelper()
{
// Force reading of environment variables.
- // This wasn't happening if UserName/Organization were
+ // This wasn't happening if UserName/Organization were
// retrieved before Credentials.
Debug.WriteIf(Credentials == null, "No credentials specified.");
}
@@ -108,10 +108,9 @@ public static string ClientSecret
get { return Environment.GetEnvironmentVariable("OCTOKIT_GHE_CLIENTSECRET"); }
}
- public static void DeleteUser(IConnection connection, User user)
+ public static string ManagementConsolePassword
{
- if (user != null)
- DeleteUser(connection, user.Login);
+ get { return Environment.GetEnvironmentVariable("OCTOKIT_GHE_CONSOLEPASSWORD"); }
}
public static void DeleteUser(IConnection connection, string username)
@@ -162,6 +161,19 @@ public static void DeletePreReceiveEnvironment(IConnection connection, PreReceiv
}
}
+ public static void SetMaintenanceMode(IConnection connection, bool enabled)
+ {
+ try
+ {
+ var client = new GitHubClient(connection);
+ client.Enterprise.ManagementConsole.EditMaintenanceMode(
+ new UpdateMaintenanceRequest(new UpdateMaintenanceRequestDetails(enabled)),
+ EnterpriseHelper.ManagementConsolePassword)
+ .Wait(TimeSpan.FromSeconds(15));
+ }
+ catch { }
+ }
+
public static IGitHubClient GetAuthenticatedClient()
{
return new GitHubClient(new ProductHeaderValue("OctokitEnterpriseTests"), GitHubEnterpriseUrl)
diff --git a/Octokit.Tests.Integration/Helpers/ApplicationTestAttribute.cs b/Octokit.Tests.Integration/Helpers/ApplicationTestAttribute.cs
index b51693c5e7..f460ebf191 100644
--- a/Octokit.Tests.Integration/Helpers/ApplicationTestAttribute.cs
+++ b/Octokit.Tests.Integration/Helpers/ApplicationTestAttribute.cs
@@ -25,7 +25,7 @@ public IEnumerable Discover(ITestFrameworkDiscoveryOptions disco
return Enumerable.Empty();
}
- return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
+ return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) };
}
}
diff --git a/Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs b/Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs
index e1ced81883..2719603a3f 100644
--- a/Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs
+++ b/Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs
@@ -22,7 +22,7 @@ public IEnumerable Discover(ITestFrameworkDiscoveryOptions disco
return Enumerable.Empty();
}
- return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
+ return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) };
}
}
diff --git a/Octokit.Tests.Integration/Helpers/DualAccountTestAttribute.cs b/Octokit.Tests.Integration/Helpers/DualAccountTestAttribute.cs
index 9d93604da5..79235d3988 100644
--- a/Octokit.Tests.Integration/Helpers/DualAccountTestAttribute.cs
+++ b/Octokit.Tests.Integration/Helpers/DualAccountTestAttribute.cs
@@ -22,7 +22,7 @@ public IEnumerable Discover(ITestFrameworkDiscoveryOptions disco
return Enumerable.Empty();
}
- return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
+ return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) };
}
}
diff --git a/Octokit.Tests.Integration/Helpers/GitHubAppsTestAttribute.cs b/Octokit.Tests.Integration/Helpers/GitHubAppsTestAttribute.cs
index cdecf74ac7..9ae83eb9d1 100644
--- a/Octokit.Tests.Integration/Helpers/GitHubAppsTestAttribute.cs
+++ b/Octokit.Tests.Integration/Helpers/GitHubAppsTestAttribute.cs
@@ -35,7 +35,7 @@ public IEnumerable Discover(ITestFrameworkDiscoveryOptions disco
return Enumerable.Empty();
}
- return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
+ return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) };
}
}
diff --git a/Octokit.Tests.Integration/Helpers/GitHubEnterpriseManagementConsoleTestAttribute.cs b/Octokit.Tests.Integration/Helpers/GitHubEnterpriseManagementConsoleTestAttribute.cs
new file mode 100644
index 0000000000..61f48df010
--- /dev/null
+++ b/Octokit.Tests.Integration/Helpers/GitHubEnterpriseManagementConsoleTestAttribute.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Xunit;
+using Xunit.Abstractions;
+using Xunit.Sdk;
+
+namespace Octokit.Tests.Integration
+{
+ public class GitHubEnterpriseManagementConsoleTestDiscoverer : IXunitTestCaseDiscoverer
+ {
+ readonly IMessageSink diagnosticMessageSink;
+
+ public GitHubEnterpriseManagementConsoleTestDiscoverer(IMessageSink diagnosticMessageSink)
+ {
+ this.diagnosticMessageSink = diagnosticMessageSink;
+ }
+
+ public IEnumerable Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
+ {
+ if (Helper.Credentials == null)
+ return Enumerable.Empty();
+
+ if (!EnterpriseHelper.IsGitHubEnterpriseEnabled)
+ return Enumerable.Empty();
+
+ if (String.IsNullOrEmpty(EnterpriseHelper.ManagementConsolePassword))
+ return Enumerable.Empty();
+
+ return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) };
+ }
+ }
+
+ [XunitTestCaseDiscoverer("Octokit.Tests.Integration.GitHubEnterpriseManagementConsoleTestDiscoverer", "Octokit.Tests.Integration")]
+ public class GitHubEnterpriseManagementConsoleTestAttribute : FactAttribute
+ {
+ }
+}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Helpers/GitHubEnterpriseTestAttribute.cs b/Octokit.Tests.Integration/Helpers/GitHubEnterpriseTestAttribute.cs
index 938bfb4641..c53df6e153 100644
--- a/Octokit.Tests.Integration/Helpers/GitHubEnterpriseTestAttribute.cs
+++ b/Octokit.Tests.Integration/Helpers/GitHubEnterpriseTestAttribute.cs
@@ -23,7 +23,7 @@ public IEnumerable Discover(ITestFrameworkDiscoveryOptions disco
if (!EnterpriseHelper.IsGitHubEnterpriseEnabled)
return Enumerable.Empty();
- return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
+ return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) };
}
}
diff --git a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs
index 1dbd2d6854..329b6360ea 100644
--- a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs
+++ b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs
@@ -79,5 +79,10 @@ internal static async Task CreateGpgKeyContext(this IGitHubClient
return new GpgKeyContext(client.Connection, key);
}
+
+ internal static MaintenanceModeContext CreateMaintenanceModeContext(this IGitHubClient client, bool enabled)
+ {
+ return new MaintenanceModeContext(client.Connection, enabled);
+ }
}
}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Helpers/IntegrationTestAttribute.cs b/Octokit.Tests.Integration/Helpers/IntegrationTestAttribute.cs
index 15efa98022..fd7ec2435f 100644
--- a/Octokit.Tests.Integration/Helpers/IntegrationTestAttribute.cs
+++ b/Octokit.Tests.Integration/Helpers/IntegrationTestAttribute.cs
@@ -19,7 +19,7 @@ public IEnumerable Discover(ITestFrameworkDiscoveryOptions disco
{
return Helper.Credentials == null
? Enumerable.Empty()
- : new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
+ : new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) };
}
}
diff --git a/Octokit.Tests.Integration/Helpers/MaintenanceModeContext.cs b/Octokit.Tests.Integration/Helpers/MaintenanceModeContext.cs
new file mode 100644
index 0000000000..26c405356a
--- /dev/null
+++ b/Octokit.Tests.Integration/Helpers/MaintenanceModeContext.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Octokit.Reactive;
+
+namespace Octokit.Tests.Integration.Helpers
+{
+ internal sealed class MaintenanceModeContext : IDisposable
+ {
+ internal MaintenanceModeContext(IConnection connection, bool enabled)
+ {
+ _connection = connection;
+
+ // Ensure maintenance mode is in the desired initial state
+ EnterpriseHelper.SetMaintenanceMode(_connection, enabled);
+ }
+
+ private IConnection _connection;
+
+ public void Dispose()
+ {
+ // Ensure maintenance mode is OFF
+ EnterpriseHelper.SetMaintenanceMode(_connection, false);
+ }
+ }
+}
diff --git a/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs
index c3656a0b07..5c52a61246 100644
--- a/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs
+++ b/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs
@@ -81,5 +81,10 @@ internal static async Task CreateGpgKeyContext(this IObservableGi
return new GpgKeyContext(client.Connection, key);
}
+
+ internal static MaintenanceModeContext CreateMaintenanceModeContext(this IObservableGitHubClient client, bool enabled)
+ {
+ return new MaintenanceModeContext(client.Connection, enabled);
+ }
}
}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs
index 7322913bda..8c36d50389 100644
--- a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs
+++ b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs
@@ -32,7 +32,7 @@ internal async static Task CreateRepositoryWithProtectedBranc
// Protect master branch
var update = new BranchProtectionSettingsUpdate(
new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }),
- new BranchProtectionRequiredReviewsUpdate(true, true),
+ new BranchProtectionRequiredReviewsUpdate(true, true, 3),
null,
true);
@@ -60,7 +60,7 @@ await client.Organization.Team.AddRepository(
// Protect master branch
var protection = new BranchProtectionSettingsUpdate(
new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }),
- new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(new BranchProtectionTeamCollection { contextOrgTeam.TeamName }), true, true),
+ new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(new BranchProtectionTeamCollection { contextOrgTeam.TeamName }), true, true, 3),
new BranchProtectionPushRestrictionsUpdate(new BranchProtectionTeamCollection { contextOrgTeam.TeamName }),
true);
await client.Repository.Branch.UpdateBranchProtection(contextOrgRepo.RepositoryOwner, contextOrgRepo.RepositoryName, "master", protection);
diff --git a/Octokit.Tests.Integration/Helpers/OrganizationTestAttribute.cs b/Octokit.Tests.Integration/Helpers/OrganizationTestAttribute.cs
index 9798ecb55b..2d886f0783 100644
--- a/Octokit.Tests.Integration/Helpers/OrganizationTestAttribute.cs
+++ b/Octokit.Tests.Integration/Helpers/OrganizationTestAttribute.cs
@@ -22,7 +22,7 @@ public IEnumerable Discover(ITestFrameworkDiscoveryOptions disco
return Enumerable.Empty();
}
- return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
+ return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) };
}
}
diff --git a/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs b/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs
index 332fec10e0..01d1ae16fa 100644
--- a/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs
+++ b/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs
@@ -23,7 +23,7 @@ public IEnumerable Discover(ITestFrameworkDiscoveryOptions disco
if (!Helper.IsPaidAccount)
return Enumerable.Empty();
- return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) };
+ return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) };
}
}
diff --git a/Octokit.Tests.Integration/Helpers/PersonalAccessTokenTestAttribute.cs b/Octokit.Tests.Integration/Helpers/PersonalAccessTokenTestAttribute.cs
index fabd5b9023..87f5d9e09f 100644
--- a/Octokit.Tests.Integration/Helpers/PersonalAccessTokenTestAttribute.cs
+++ b/Octokit.Tests.Integration/Helpers/PersonalAccessTokenTestAttribute.cs
@@ -18,7 +18,7 @@ public PersonalAccessTokenTestDiscoverer(IMessageSink diagnosticMessageSink)
public IEnumerable Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
return Helper.IsUsingToken
- ? new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) }
+ ? new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) }
: Enumerable.Empty();
}
}
diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
index c38f326981..29e43af0e7 100644
--- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
+++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
@@ -4,7 +4,7 @@
Integration tests for Octokit
Octokit.Tests.Integration
GitHub
- netcoreapp2.0;net452
+ netcoreapp3.1;net452
$(NoWarn);CS4014;CS1998
Octokit.Tests.Integration
Octokit.Tests.Integration
@@ -19,7 +19,7 @@
false
-
+
$(DefineConstants);GITHUBJWT_HELPER_AVAILABLE
@@ -36,19 +36,21 @@
-
-
-
+
+
+
-
-
- 0.0.2
-
+
+
+
+
+
+
diff --git a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseManagementConsoleTests.cs b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseManagementConsoleTests.cs
new file mode 100644
index 0000000000..9311f5a88b
--- /dev/null
+++ b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseManagementConsoleTests.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Linq;
+using System.Reactive.Linq;
+using System.Threading.Tasks;
+using Octokit.Reactive;
+using Octokit.Tests.Integration.Helpers;
+using Xunit;
+
+namespace Octokit.Tests.Integration
+{
+ public class ObservableEnterpriseManagementConsoleTests
+ {
+ readonly IObservableGitHubClient _github;
+
+ public ObservableEnterpriseManagementConsoleTests()
+ {
+ _github = new ObservableGitHubClient(EnterpriseHelper.GetAuthenticatedClient());
+ }
+
+ [GitHubEnterpriseManagementConsoleTest]
+ public async Task CanGetMaintenanceMode()
+ {
+ var maintenance = await _github.Enterprise.ManagementConsole.GetMaintenanceMode(EnterpriseHelper.ManagementConsolePassword);
+
+ Assert.NotNull(maintenance);
+ }
+
+ [GitHubEnterpriseManagementConsoleTest]
+ public async Task CanSetMaintenanceModeOff()
+ {
+ using (_github.CreateMaintenanceModeContext(true))
+ {
+ // Set maintenance mode OFF now
+ var maintenance = await
+ _github.Enterprise.ManagementConsole.EditMaintenanceMode(
+ new UpdateMaintenanceRequest(),
+ EnterpriseHelper.ManagementConsolePassword);
+
+ Assert.Equal(MaintenanceModeStatus.Off, maintenance.Status);
+ }
+ }
+
+ [GitHubEnterpriseManagementConsoleTest]
+ public async Task CanSetMaintenanceModeOnNow()
+ {
+ using (_github.CreateMaintenanceModeContext(false))
+ {
+ // Set maintenance mode ON now
+ var maintenance = await
+ _github.Enterprise.ManagementConsole.EditMaintenanceMode(
+ new UpdateMaintenanceRequest(
+ new UpdateMaintenanceRequestDetails(true)),
+ EnterpriseHelper.ManagementConsolePassword);
+
+ Assert.Equal(MaintenanceModeStatus.On, maintenance.Status);
+ }
+ }
+
+ [GitHubEnterpriseManagementConsoleTest]
+ public async Task CanScheduleMaintenanceModeOnWithDateTime()
+ {
+ using (_github.CreateMaintenanceModeContext(false))
+ {
+ // Schedule maintenance mode ON in 5 minutes
+ var scheduledTime = DateTimeOffset.Now.AddMinutes(5);
+ var maintenance = await
+ _github.Enterprise.ManagementConsole.EditMaintenanceMode(
+ new UpdateMaintenanceRequest(
+ new UpdateMaintenanceRequestDetails(true, scheduledTime)),
+ EnterpriseHelper.ManagementConsolePassword);
+
+ Assert.Equal(MaintenanceModeStatus.Scheduled, maintenance.Status);
+ }
+ }
+
+ [GitHubEnterpriseManagementConsoleTest]
+ public async Task CanScheduleMaintenanceModeOnWithPhrase()
+ {
+ using (_github.CreateMaintenanceModeContext(false))
+ {
+ // Schedule maintenance mode ON with phrase
+ var maintenance = await
+ _github.Enterprise.ManagementConsole.EditMaintenanceMode(
+ new UpdateMaintenanceRequest(
+ new UpdateMaintenanceRequestDetails(true, "tomorrow at 5pm")),
+ EnterpriseHelper.ManagementConsolePassword);
+
+ Assert.Equal(MaintenanceModeStatus.Scheduled, maintenance.Status);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs
index f4e752d65d..68cc68df07 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs
@@ -133,7 +133,7 @@ public async Task UpdatesPreferences()
Assert.Equal(repoContext.RepositoryId, result.Repository.Id);
Assert.Equal(Helper.GitHubAppId, result.Preferences.AutoTriggerChecks[0].AppId);
- Assert.Equal(false, result.Preferences.AutoTriggerChecks[0].Setting);
+ Assert.False(result.Preferences.AutoTriggerChecks[0].Setting);
}
}
@@ -150,7 +150,7 @@ public async Task UpdatesPreferencesWithRepositoryId()
Assert.Equal(repoContext.RepositoryId, result.Repository.Id);
Assert.Equal(Helper.GitHubAppId, result.Preferences.AutoTriggerChecks[0].AppId);
- Assert.Equal(false, result.Preferences.AutoTriggerChecks[0].Setting);
+ Assert.False(result.Preferences.AutoTriggerChecks[0].Setting);
}
}
}
diff --git a/Octokit.Tests.Integration/Reactive/ObservableOrganizationMembersClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableOrganizationMembersClientTests.cs
index aea37f8470..6095584ba3 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableOrganizationMembersClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableOrganizationMembersClientTests.cs
@@ -1,4 +1,5 @@
using System.Reactive.Linq;
+using System.Reactive.Threading.Tasks;
using System.Threading.Tasks;
using Octokit.Reactive;
using Octokit.Tests.Integration.Helpers;
@@ -8,6 +9,78 @@ namespace Octokit.Tests.Integration.Reactive
{
public class ObservableOrganizationMembersClientTests
{
+ public class TheGetOrganizationMembershipMethod
+ {
+ readonly IGitHubClient _gitHub;
+ readonly ObservableOrganizationMembersClient _client;
+
+ public TheGetOrganizationMembershipMethod()
+ {
+ _gitHub = Helper.GetAuthenticatedClient();
+ _client = new ObservableOrganizationMembersClient(_gitHub);
+ }
+
+ [OrganizationTest]
+ public async Task ReturnsUsersMembershipOrganizationMembership()
+ {
+ using (var teamContext = await _gitHub.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
+ {
+ teamContext.InviteMember("alfhenrik-test-2");
+
+ var organizationMemberhip = await _client.GetOrganizationMembership(Helper.Organization, "alfhenrik-test-2");
+ Assert.Equal(MembershipState.Pending, organizationMemberhip.State);
+ Assert.Equal(MembershipRole.Member, organizationMemberhip.Role);
+ await _client.RemoveOrganizationMembership(Helper.Organization, "alfhenrik-test-2");
+ }
+ }
+ }
+
+ public class TheAddOrUpdateOrganizationMembershipMethod
+ {
+ readonly ObservableOrganizationMembersClient _client;
+
+ public TheAddOrUpdateOrganizationMembershipMethod()
+ {
+ _client = new ObservableOrganizationMembersClient(Helper.GetAuthenticatedClient());
+ }
+
+ [OrganizationTest]
+ public async Task ReturnsUsersPendingMemberOrganizationMembership()
+ {
+ var organizationMembership = await _client.AddOrUpdateOrganizationMembership(Helper.Organization, "alfhenrik-test-2", new OrganizationMembershipUpdate());
+ Assert.Equal(MembershipState.Pending, organizationMembership.State);
+ Assert.Equal(MembershipRole.Member, organizationMembership.Role);
+ await _client.RemoveOrganizationMembership(Helper.Organization, "alfhenrik-test-2");
+ }
+
+ [OrganizationTest]
+ public async Task ReturnsUsersPendingAdminOrganizationMembership()
+ {
+ var organizationMembership = await _client.AddOrUpdateOrganizationMembership(Helper.Organization, "alfhenrik-test-2", new OrganizationMembershipUpdate { Role = MembershipRole.Admin });
+ Assert.Equal(MembershipState.Pending, organizationMembership.State);
+ Assert.Equal(MembershipRole.Admin, organizationMembership.Role);
+ await _client.RemoveOrganizationMembership(Helper.Organization, "alfhenrik-test-2");
+ }
+ }
+
+ public class TheRemoveOrganizationMembershipMethod
+ {
+ readonly ObservableOrganizationMembersClient _client;
+
+ public TheRemoveOrganizationMembershipMethod()
+ {
+ _client = new ObservableOrganizationMembersClient(Helper.GetAuthenticatedClient());
+ }
+
+ [OrganizationTest]
+ public async Task RemovesOrganizationMembership()
+ {
+ await _client.AddOrUpdateOrganizationMembership(Helper.Organization, "alfhenrik-test-2", new OrganizationMembershipUpdate());
+ await _client.RemoveOrganizationMembership(Helper.Organization, "alfhenrik-test-2");
+ await Assert.ThrowsAsync(() => _client.GetOrganizationMembership(Helper.Organization, "alfhenrik-test-2").ToTask());
+ }
+ }
+
public class TheGetAllPendingInvitationsMethod
{
readonly IGitHubClient _gitHub;
diff --git a/Octokit.Tests.Integration/Reactive/ObservableReleaseClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableReleaseClientTests.cs
index c5349c8571..537ba78298 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableReleaseClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableReleaseClientTests.cs
@@ -101,9 +101,9 @@ public async Task ReturnsReleaseByTag()
{
var releaseByTag = await _releaseClient.Get("octokit", "octokit.net", "v0.28.0");
- Assert.Equal(releaseByTag.Id, 8396883);
- Assert.Equal(releaseByTag.Name, "v0.28 - Get to the Chopper!!!");
- Assert.Equal(releaseByTag.TagName, "v0.28.0");
+ Assert.Equal(8396883, releaseByTag.Id);
+ Assert.Equal("v0.28 - Get to the Chopper!!!", releaseByTag.Name);
+ Assert.Equal("v0.28.0", releaseByTag.TagName);
}
[IntegrationTest]
@@ -111,9 +111,9 @@ public async Task ReturnsReleaseWithRepositoryIdByTag()
{
var releaseByTag = await _releaseClient.Get(7528679, "v0.28.0");
- Assert.Equal(releaseByTag.Id, 8396883);
- Assert.Equal(releaseByTag.Name, "v0.28 - Get to the Chopper!!!");
- Assert.Equal(releaseByTag.TagName, "v0.28.0");
+ Assert.Equal(8396883, releaseByTag.Id);
+ Assert.Equal("v0.28 - Get to the Chopper!!!", releaseByTag.Name);
+ Assert.Equal("v0.28.0", releaseByTag.TagName);
}
[IntegrationTest]
diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs
index db4ea1b58e..8cbac07c59 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs
@@ -38,6 +38,7 @@ public async Task GetsBranchProtection()
Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions);
Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews);
Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews);
+ Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount);
Assert.Null(protection.Restrictions);
@@ -56,6 +57,7 @@ public async Task GetsBranchProtectionWithRepositoryId()
Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions);
Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews);
Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews);
+ Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount);
Assert.Null(protection.Restrictions);
@@ -76,6 +78,7 @@ public async Task GetsBranchProtectionForOrgRepo()
Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count);
Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews);
Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews);
+ Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount);
Assert.Equal(1, protection.Restrictions.Teams.Count);
Assert.Equal(0, protection.Restrictions.Users.Count);
@@ -96,6 +99,7 @@ public async Task GetsBranchProtectionForOrgRepoWithRepositoryId()
Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count);
Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews);
Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews);
+ Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount);
Assert.Equal(1, protection.Restrictions.Teams.Count);
Assert.Equal(0, protection.Restrictions.Users.Count);
@@ -135,7 +139,7 @@ public async Task UpdatesBranchProtection()
var repoName = _userRepoContext.RepositoryName;
var update = new BranchProtectionSettingsUpdate(
new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }),
- new BranchProtectionRequiredReviewsUpdate(false, true),
+ new BranchProtectionRequiredReviewsUpdate(false, true, 2),
false);
var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "master", update);
@@ -146,6 +150,7 @@ public async Task UpdatesBranchProtection()
Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions);
Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews);
Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews);
+ Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount);
Assert.Null(protection.Restrictions);
@@ -158,7 +163,7 @@ public async Task UpdatesBranchProtectionWithRepositoryId()
var repoId = _userRepoContext.RepositoryId;
var update = new BranchProtectionSettingsUpdate(
new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }),
- new BranchProtectionRequiredReviewsUpdate(false, true),
+ new BranchProtectionRequiredReviewsUpdate(false, true, 2),
false);
var protection = await _client.UpdateBranchProtection(repoId, "master", update);
@@ -169,6 +174,7 @@ public async Task UpdatesBranchProtectionWithRepositoryId()
Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions);
Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews);
Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews);
+ Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount);
Assert.Null(protection.Restrictions);
@@ -182,7 +188,7 @@ public async Task UpdatesBranchProtectionForOrgRepo()
var repoName = _orgRepoContext.RepositoryContext.RepositoryName;
var update = new BranchProtectionSettingsUpdate(
new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }),
- new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false),
+ new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2),
new BranchProtectionPushRestrictionsUpdate(),
false);
@@ -194,6 +200,7 @@ public async Task UpdatesBranchProtectionForOrgRepo()
Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions);
Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews);
Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews);
+ Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount);
Assert.Empty(protection.Restrictions.Teams);
Assert.Empty(protection.Restrictions.Users);
@@ -207,7 +214,7 @@ public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId()
var repoId = _orgRepoContext.RepositoryContext.RepositoryId;
var update = new BranchProtectionSettingsUpdate(
new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }),
- new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false),
+ new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2),
new BranchProtectionPushRestrictionsUpdate(),
false);
@@ -219,6 +226,7 @@ public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId()
Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions);
Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews);
Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews);
+ Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount);
Assert.Empty(protection.Restrictions.Teams);
Assert.Empty(protection.Restrictions.Users);
@@ -391,26 +399,28 @@ public async Task UpdatesReviewEnforcement()
{
var repoOwner = _userRepoContext.RepositoryOwner;
var repoName = _userRepoContext.RepositoryName;
- var update = new BranchProtectionRequiredReviewsUpdate(false, true);
+ var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2);
var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update);
Assert.Null(requiredReviews.DismissalRestrictions);
Assert.False(requiredReviews.DismissStaleReviews);
Assert.True(requiredReviews.RequireCodeOwnerReviews);
+ Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount);
}
[IntegrationTest]
public async Task UpdatesReviewEnforcementWithRepositoryId()
{
var repoId = _userRepoContext.RepositoryId;
- var update = new BranchProtectionRequiredReviewsUpdate(false, true);
+ var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2);
var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update);
Assert.Null(requiredReviews.DismissalRestrictions);
Assert.False(requiredReviews.DismissStaleReviews);
Assert.True(requiredReviews.RequireCodeOwnerReviews);
+ Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount);
}
[IntegrationTest]
@@ -421,13 +431,15 @@ public async Task UpdatesReviewEnforcementForOrgRepo()
var update = new BranchProtectionRequiredReviewsUpdate(
new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false),
false,
- false);
+ false,
+ 2);
var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update);
Assert.Null(requiredReviews.DismissalRestrictions);
Assert.False(requiredReviews.DismissStaleReviews);
Assert.False(requiredReviews.RequireCodeOwnerReviews);
+ Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount);
}
[IntegrationTest]
@@ -437,13 +449,15 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithRepositoryId()
var update = new BranchProtectionRequiredReviewsUpdate(
new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false),
false,
- false);
+ false,
+ 2);
var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update);
Assert.Null(requiredReviews.DismissalRestrictions);
Assert.False(requiredReviews.DismissStaleReviews);
Assert.False(requiredReviews.RequireCodeOwnerReviews);
+ Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount);
}
[IntegrationTest]
@@ -454,7 +468,8 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly()
var update = new BranchProtectionRequiredReviewsUpdate(
new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true),
false,
- false);
+ false,
+ 2);
var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update);
@@ -471,7 +486,8 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryI
var update = new BranchProtectionRequiredReviewsUpdate(
new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true),
false,
- false);
+ false,
+ 2);
var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update);
@@ -479,6 +495,7 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryI
Assert.Empty(requiredReviews.DismissalRestrictions.Users);
Assert.False(requiredReviews.DismissStaleReviews);
Assert.False(requiredReviews.RequireCodeOwnerReviews);
+ Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount);
}
public void Dispose()
diff --git a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs
index bcc97ec37f..0e8133659d 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs
@@ -30,8 +30,8 @@ public async Task GetsChildTeams()
var teams = await _github.Organization.Team.GetAllChildTeams(parentTeamContext.TeamId).ToList();
Assert.Equal(2, teams.Count);
- Assert.True(teams.Any(x => x.Id == team1.Id));
- Assert.True(teams.Any(x => x.Id == team2.Id));
+ Assert.Contains(teams, x => x.Id == team1.Id);
+ Assert.Contains(teams, x => x.Id == team2.Id);
}
}
diff --git a/Octokit.Tests.Integration/Reactive/ObservableUserGpgKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableUserGpgKeysClientTests.cs
index 0d6878c44d..eb10a3c59a 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableUserGpgKeysClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableUserGpgKeysClientTests.cs
@@ -33,7 +33,7 @@ public async Task CanGetAllForCurrentUser()
Assert.NotEmpty(keys);
var first = keys[0];
- Assert.NotNull(first.Id);
+ Assert.NotEqual(default, first.Id);
Assert.Null(first.PrimaryKeyId);
Assert.NotNull(first.KeyId);
Assert.NotNull(first.PublicKey);
@@ -89,7 +89,7 @@ public async Task CanCreateAndDeleteKey()
// Verify key no longer exists
var keys = await _gitHubClient.User.GpgKey.GetAllForCurrent().ToList();
- Assert.False(keys.Any(k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey));
+ Assert.DoesNotContain(keys, k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey);
}
}
}
diff --git a/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs
index 61cbf8628e..d35aee12aa 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs
@@ -27,7 +27,7 @@ public async Task CanGetAllForCurrentUser()
Assert.NotEmpty(keys);
var first = keys[0];
- Assert.NotNull(first.Id);
+ Assert.True(first.Id > 0);
Assert.NotNull(first.Key);
Assert.NotNull(first.Title);
Assert.NotNull(first.Url);
@@ -43,7 +43,7 @@ public async Task CanGetAllForGivenUser()
Assert.NotEmpty(keys);
var first = keys[0];
- Assert.NotNull(first.Id);
+ Assert.True(first.Id > 0);
Assert.NotNull(first.Key);
Assert.Null(first.Title);
Assert.Null(first.Url);
@@ -81,7 +81,7 @@ public async Task CanCreateAndDeleteKey()
// Verify key no longer exists
var keys = await _github.User.GitSshKey.GetAllForCurrent().ToList();
- Assert.False(keys.Any(k => k.Title == keyTitle && k.Key == keyData));
+ Assert.DoesNotContain(keys, k => k.Title == keyTitle && k.Key == keyData);
}
}
}
diff --git a/Octokit.Tests.Integration/RedirectTests.cs b/Octokit.Tests.Integration/RedirectTests.cs
index 012be7a8c3..a024399d87 100644
--- a/Octokit.Tests.Integration/RedirectTests.cs
+++ b/Octokit.Tests.Integration/RedirectTests.cs
@@ -31,7 +31,7 @@ public async Task CanCreateIssueOnRedirectedRepository()
var issue = await client.Issue.Create(owner, oldRepoName, newIssue);
Assert.NotNull(issue);
- Assert.True(issue.Url.Contains("repository-after-rename"));
+ Assert.Contains("repository-after-rename", issue.Url);
var resolvedIssue = await client.Issue.Get(owner, newRepoName, issue.Number);
diff --git a/Octokit.Tests/Clients/AuthorizationsClientTests.cs b/Octokit.Tests/Clients/AuthorizationsClientTests.cs
index 8314fddafd..5851071246 100644
--- a/Octokit.Tests/Clients/AuthorizationsClientTests.cs
+++ b/Octokit.Tests/Clients/AuthorizationsClientTests.cs
@@ -271,7 +271,7 @@ public async Task GetsOrCreatesAuthenticationWithFingerprintAtCorrectUrl()
authEndpoint.GetOrCreateApplicationAuthentication("clientId", "secret", data);
Assert.NotNull(calledUri);
- Assert.Equal(calledUri.ToString(), "authorizations/clients/clientId");
+ Assert.Equal("authorizations/clients/clientId", calledUri.ToString());
Assert.NotNull(calledBody);
var fingerprintProperty = ((IEnumerable)calledBody.GetType().DeclaredProperties).FirstOrDefault(x => x.Name == "fingerprint");
diff --git a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs
index 0f55c0e8a4..fe9dc39b35 100644
--- a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs
+++ b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Runtime.InteropServices.ComTypes;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;
@@ -26,7 +27,25 @@ public async Task RequestsCorrectUrl()
await client.GetAll("fake", "repo", 42);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), "application/vnd.github.squirrel-girl-preview");
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new CommitCommentReactionsClient(connection);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ StartPage = 1,
+ PageSize = 1
+ };
+
+ await client.GetAll("fake", "repo", 42, options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
}
[Fact]
@@ -37,7 +56,25 @@ public async Task RequestsCorrectUrlWithRepositoryId()
await client.GetAll(1, 42);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/comments/42/reactions"), "application/vnd.github.squirrel-girl-preview");
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new CommitCommentReactionsClient(connection);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ StartPage = 1,
+ PageSize = 1
+ };
+
+ await client.GetAll(1, 42, options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
}
[Fact]
@@ -48,10 +85,20 @@ public async Task EnsuresNotNullArguments()
await Assert.ThrowsAsync(() => client.GetAll(null, "name", 1));
await Assert.ThrowsAsync(() => client.GetAll("owner", null, 1));
+ await Assert.ThrowsAsync(() => client.GetAll("owner", "name", 1, null));
await Assert.ThrowsAsync(() => client.GetAll("", "name", 1));
await Assert.ThrowsAsync(() => client.GetAll("owner", "", 1));
}
+
+ [Fact]
+ public async Task EnsuresNotNullArgumentsWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new CommitCommentReactionsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetAll(1, 1, null));
+ }
}
public class TheCreateMethod
diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseManagementConsoleClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseManagementConsoleClientTests.cs
new file mode 100644
index 0000000000..6ba091b80c
--- /dev/null
+++ b/Octokit.Tests/Clients/Enterprise/EnterpriseManagementConsoleClientTests.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Threading.Tasks;
+using NSubstitute;
+using Xunit;
+
+namespace Octokit.Tests.Clients
+{
+ public class EnterpriseManagementConsoleClientTests
+ {
+ public class TheGetMaintenanceModeMethod
+ {
+ [Fact]
+ public void RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new EnterpriseManagementConsoleClient(connection);
+
+ string expectedUri = "setup/api/maintenance?api_key=Password01";
+ client.GetMaintenanceMode("Password01");
+
+ connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri));
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new EnterpriseManagementConsoleClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetMaintenanceMode(null));
+ }
+
+ [Fact]
+ public async Task EnsuresNonEmptyArguments()
+ {
+ var connection = Substitute.For();
+ var client = new EnterpriseManagementConsoleClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetMaintenanceMode(""));
+ }
+ }
+
+ public class TheEditMaintenanceModeMethod
+ {
+ [Fact]
+ public void RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new EnterpriseManagementConsoleClient(connection);
+
+ string expectedUri = "setup/api/maintenance?api_key=Password01";
+ client.EditMaintenanceMode(new UpdateMaintenanceRequest(), "Password01");
+
+ connection.Received().Post(
+ Arg.Is(u => u.ToString() == expectedUri),
+ Arg.Any());
+ }
+
+ [Fact]
+ public void PassesRequestObject()
+ {
+ var connection = Substitute.For();
+ var client = new EnterpriseManagementConsoleClient(connection);
+
+ client.EditMaintenanceMode(new UpdateMaintenanceRequest(new UpdateMaintenanceRequestDetails(true)), "Password01");
+
+ connection.Received().Post(
+ Arg.Any(),
+ Arg.Is(a =>
+ a == "maintenance={\"enabled\":true,\"when\":\"now\"}"));
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new EnterpriseManagementConsoleClient(connection);
+
+ await Assert.ThrowsAsync(() => client.EditMaintenanceMode(null, "Password01"));
+ await Assert.ThrowsAsync(() => client.EditMaintenanceMode(new UpdateMaintenanceRequest(), null));
+ }
+
+ [Fact]
+ public async Task EnsuresNonEmptyArguments()
+ {
+ var connection = Substitute.For();
+ var client = new EnterpriseManagementConsoleClient(connection);
+
+ await Assert.ThrowsAsync(() => client.EditMaintenanceMode(new UpdateMaintenanceRequest(), ""));
+ }
+ }
+
+ public class TheCtor
+ {
+ [Fact]
+ public void EnsuresNonNullArguments()
+ {
+ Assert.Throws(() => new EnterpriseManagementConsoleClient(null));
+ }
+ }
+ }
+}
diff --git a/Octokit.Tests/Clients/EventsClientTests.cs b/Octokit.Tests/Clients/EventsClientTests.cs
index 99a65a7cd4..fb38f29252 100644
--- a/Octokit.Tests/Clients/EventsClientTests.cs
+++ b/Octokit.Tests/Clients/EventsClientTests.cs
@@ -556,6 +556,8 @@ public async Task EnsuresNonNullArguments()
{"CheckRunEvent", typeof(CheckRunEventPayload)},
{"CheckSuiteEvent", typeof(CheckSuiteEventPayload)},
{"CommitCommentEvent", typeof(CommitCommentPayload)},
+ {"CreateEvent", typeof(CreateEventPayload)},
+ {"DeleteEvent", typeof(DeleteEventPayload)},
{"ForkEvent", typeof(ForkEventPayload)},
{"IssueCommentEvent", typeof(IssueCommentPayload)},
{"IssuesEvent", typeof(IssueEventPayload)},
@@ -623,6 +625,54 @@ public async Task DeserializesCommitCommentEventCorrectly()
Assert.Equal(1337, payload.Comment.Id);
}
+ [Fact]
+ public async Task DeserializesCreateEventCorrectly()
+ {
+ var jsonObj = new JsonObject
+ {
+ { "type", "CreateEvent" },
+ {
+ "payload", new
+ {
+ @ref = "master",
+ ref_type = "branch",
+ }
+ }
+ };
+
+ var client = GetTestingEventsClient(jsonObj);
+ var activities = await client.GetAll();
+ Assert.Equal(1, activities.Count);
+
+ var payload = activities.FirstOrDefault().Payload as CreateEventPayload;
+ Assert.Equal("master", payload.Ref);
+ Assert.Equal(RefType.Branch, payload.RefType);
+ }
+
+ [Fact]
+ public async Task DeserializesDeleteEventCorrectly()
+ {
+ var jsonObj = new JsonObject
+ {
+ { "type", "DeleteEvent" },
+ {
+ "payload", new
+ {
+ @ref = "master",
+ ref_type = "branch",
+ }
+ }
+ };
+
+ var client = GetTestingEventsClient(jsonObj);
+ var activities = await client.GetAll();
+ Assert.Equal(1, activities.Count);
+
+ var payload = activities.FirstOrDefault().Payload as DeleteEventPayload;
+ Assert.Equal("master", payload.Ref);
+ Assert.Equal(RefType.Branch, payload.RefType);
+ }
+
[Fact]
public async Task DeserializesForkEventCorrectly()
{
diff --git a/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs b/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs
index 971fc225c6..ed64332c64 100644
--- a/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs
+++ b/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs
@@ -26,7 +26,25 @@ public async Task RequestsCorrectUrl()
await client.GetAll("fake", "repo", 42);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), "application/vnd.github.squirrel-girl-preview");
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new IssueCommentReactionsClient(connection);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ StartPage = 1,
+ PageSize = 1
+ };
+
+ await client.GetAll("fake", "repo", 42, options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
}
[Fact]
@@ -37,7 +55,25 @@ public async Task RequestsCorrectUrlWithRepositoryId()
await client.GetAll(1, 42);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), "application/vnd.github.squirrel-girl-preview");
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new IssueCommentReactionsClient(connection);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ StartPage = 1,
+ PageSize = 1
+ };
+
+ await client.GetAll(1, 42, options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
}
[Fact]
@@ -48,10 +84,20 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync(() => client.GetAll(null, "name", 1));
await Assert.ThrowsAsync(() => client.GetAll("owner", null, 1));
+ await Assert.ThrowsAsync(() => client.GetAll("owner", "name", 1, null));
await Assert.ThrowsAsync(() => client.GetAll("", "name", 1));
await Assert.ThrowsAsync(() => client.GetAll("owner", "", 1));
}
+
+ [Fact]
+ public async Task EnsuresNonNullArgumentsWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new IssueCommentReactionsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetAll(1, 1, null));
+ }
}
public class TheCreateMethod
diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs
index ff5a5ef9f3..884b22f191 100644
--- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs
+++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs
@@ -180,6 +180,45 @@ public async Task RequestsCorrectUrlWithRepositoryId()
Args.ApiOptions);
}
+ [Fact]
+ public async Task RequestsCorrectUrlWithIssueCommentRequest()
+ {
+ var connection = Substitute.For();
+ var client = new IssueCommentsClient(connection);
+
+ var request = new IssueCommentRequest()
+ {
+ Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()),
+ };
+
+ await client.GetAllForIssue("fake", "repo", 3, request);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments"),
+ Arg.Any>(),
+ "application/vnd.github.squirrel-girl-preview",
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryIdWithIssueCommentRequest()
+ {
+ var connection = Substitute.For();
+ var client = new IssueCommentsClient(connection);
+
+ var request = new IssueCommentRequest()
+ {
+ Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()),
+ };
+
+ await client.GetAllForIssue(1, 3, request);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/3/comments"),
+ Arg.Any>(),
+ "application/vnd.github.squirrel-girl-preview",
+ Args.ApiOptions);
+ }
+
[Fact]
public async Task RequestsCorrectUrlWithApiOptions()
{
@@ -233,9 +272,13 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", null, 1));
await Assert.ThrowsAsync(() => client.GetAllForIssue(null, "name", 1, ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", null, 1, ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "name", 1, null));
+ await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "name", 1, options: null));
+ await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "name", 1, request: null));
+ await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "name", 1, null, ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForIssue(1, 1, null));
+ await Assert.ThrowsAsync(() => client.GetAllForIssue(1, 1, options: null));
+ await Assert.ThrowsAsync(() => client.GetAllForIssue(1, 1, request: null));
+ await Assert.ThrowsAsync(() => client.GetAllForIssue(1, 1, null, ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1));
await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1));
diff --git a/Octokit.Tests/Clients/IssueReactionsClientTests.cs b/Octokit.Tests/Clients/IssueReactionsClientTests.cs
index 3c0ab6be6c..cbe9e390f8 100644
--- a/Octokit.Tests/Clients/IssueReactionsClientTests.cs
+++ b/Octokit.Tests/Clients/IssueReactionsClientTests.cs
@@ -26,7 +26,25 @@ public async Task RequestsCorrectUrl()
await client.GetAll("fake", "repo", 42);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), "application/vnd.github.squirrel-girl-preview");
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new IssueReactionsClient(connection);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ StartPage = 1,
+ PageSize = 1
+ };
+
+ await client.GetAll("fake", "repo", 42, options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
}
[Fact]
@@ -37,7 +55,25 @@ public async Task RequestsCorrectUrlWithRepositoryId()
await client.GetAll(1, 42);
- connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/42/reactions"), "application/vnd.github.squirrel-girl-preview");
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new IssueReactionsClient(connection);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ StartPage = 1,
+ PageSize = 1
+ };
+
+ await client.GetAll(1, 42, options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
}
[Fact]
@@ -48,10 +84,20 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync(() => client.Issue.GetAll(null, "name", 1));
await Assert.ThrowsAsync(() => client.Issue.GetAll("owner", null, 1));
+ await Assert.ThrowsAsync(() => client.Issue.GetAll("owner", "name", 1, null));
await Assert.ThrowsAsync(() => client.Issue.GetAll("", "name", 1));
await Assert.ThrowsAsync(() => client.Issue.GetAll("owner", "", 1));
}
+
+ [Fact]
+ public async Task EnsuresNonNullArgumentsWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new ReactionsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.Issue.GetAll(1, 1, null));
+ }
}
public class TheCreateMethod
diff --git a/Octokit.Tests/Clients/MigrationsClientTests.cs b/Octokit.Tests/Clients/MigrationsClientTests.cs
index a1d610a254..5dac36012b 100644
--- a/Octokit.Tests/Clients/MigrationsClientTests.cs
+++ b/Octokit.Tests/Clients/MigrationsClientTests.cs
@@ -55,10 +55,32 @@ public void RequestsCorrectUrl()
client.GetAll("fake");
- connection.Received().Get>(
+ connection.Received().GetAll(
Arg.Is(u => u.ToString() == "orgs/fake/migrations"),
null,
- AcceptHeaders.MigrationsApiPreview);
+ AcceptHeaders.MigrationsApiPreview,
+ Args.ApiOptions);
+ }
+
+ [Fact]
+ public void RequestsCorrectUrlApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new MigrationsClient(connection);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 1
+ };
+
+ client.GetAll("fake", options);
+
+ connection.Received().GetAll(
+ Arg.Is(u => u.ToString() == "orgs/fake/migrations"),
+ null,
+ AcceptHeaders.MigrationsApiPreview,
+ options);
}
[Fact]
@@ -68,6 +90,7 @@ public async Task EnsuresNonNullAndNonEmptyArguments()
var client = new MigrationsClient(connection);
await Assert.ThrowsAsync(() => client.GetAll(null));
+ await Assert.ThrowsAsync(() => client.GetAll("fake", null));
await Assert.ThrowsAsync