Add Importer property to Meta response model

Implement unit test for GetMetadata() call
Flesh out integration test to check all returned Meta fields
-> Found and fixed a bug where the existing `GitHubServicesSHA` field was not deserialised properly
This commit is contained in:
Ryan Gribble
2016-04-03 21:56:30 +10:00
parent 9231286fed
commit a489092f62
3 changed files with 51 additions and 1 deletions
@@ -113,6 +113,11 @@ public class MiscellaneousClientTests
var result = await github.Miscellaneous.GetMetadata();
Assert.True(result.VerifiablePasswordAuthentication);
Assert.NotEmpty(result.GitHubServicesSha);
Assert.True(result.Hooks.Count > 0);
Assert.True(result.Git.Count > 0);
Assert.True(result.Pages.Count > 0);
Assert.True(result.Importer.Count > 0);
}
}
}
@@ -136,6 +136,42 @@ namespace Octokit.Tests.Clients
}
}
public class TheGetMetadataMethod
{
[Fact]
public async Task RequestsTheMetadataEndpoint()
{
IApiResponse<Meta> response = new ApiResponse<Meta>
(
new Response(),
new Meta(
false,
"12345ABCDE",
new[] { "1.1.1.1/24", "1.1.1.2/24" },
new[] { "1.1.2.1/24", "1.1.2.2/24" },
new[] { "1.1.3.1/24", "1.1.3.2/24" },
new[] { "1.1.4.1", "1.1.4.2" }
)
);
var connection = Substitute.For<IConnection>();
connection.Get<Meta>(Args.Uri, null, null)
.Returns(Task.FromResult(response));
var client = new MiscellaneousClient(connection);
var result = await client.GetMetadata();
Assert.Equal(result.VerifiablePasswordAuthentication, false);
Assert.Equal(result.GitHubServicesSha, "12345ABCDE");
Assert.Equal(result.Hooks, new[] { "1.1.1.1/24", "1.1.1.2/24" });
Assert.Equal(result.Git, new[] { "1.1.2.1/24", "1.1.2.2/24" });
Assert.Equal(result.Pages, new[] { "1.1.3.1/24", "1.1.3.2/24" });
Assert.Equal(result.Importer, new[] { "1.1.4.1", "1.1.4.2" });
connection.Received()
.Get<Meta>(Arg.Is<Uri>(u => u.ToString() == "meta"), null, null);
}
}
public class TheCtor
{
[Fact]
+10 -1
View File
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using Octokit.Internal;
namespace Octokit
{
@@ -30,13 +31,15 @@ namespace Octokit
string gitHubServicesSha,
IReadOnlyList<string> hooks,
IReadOnlyList<string> git,
IReadOnlyList<string> pages)
IReadOnlyList<string> pages,
IReadOnlyList<string> importer)
{
VerifiablePasswordAuthentication = verifiablePasswordAuthentication;
GitHubServicesSha = gitHubServicesSha;
Hooks = hooks;
Git = git;
Pages = pages;
Importer = importer;
}
/// <summary>
@@ -49,6 +52,7 @@ namespace Octokit
/// <summary>
/// The currently-deployed SHA of github-services.
/// </summary>
[Parameter(Key = "github_services_sha")]
public string GitHubServicesSha { get; private set; }
/// <summary>
@@ -68,6 +72,11 @@ namespace Octokit
/// </summary>
public IReadOnlyList<string> Pages { get; private set; }
/// <summary>
/// An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com.
/// </summary>
public IReadOnlyList<string> Importer { get; private set; }
internal string DebuggerDisplay
{
get