mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-04 11:24:44 +00:00
debug implementation while writing integration tests
- fix Update method PUT parameters - add [SerializeNull] to various request fields - fix deserialize problem with ProtectedBranchRestrictions ctor not being public - tidy up DebuggerDisplay output
This commit is contained in:
@@ -263,7 +263,7 @@ namespace Octokit.Tests.Clients
|
||||
client.UpdateBranchProtection("owner", "repo", "branch", update);
|
||||
|
||||
connection.Received()
|
||||
.Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), previewAcceptsHeader);
|
||||
.Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null, previewAcceptsHeader);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -278,7 +278,7 @@ namespace Octokit.Tests.Clients
|
||||
client.UpdateBranchProtection(1, "branch", update);
|
||||
|
||||
connection.Received()
|
||||
.Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), previewAcceptsHeader);
|
||||
.Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null, previewAcceptsHeader);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");
|
||||
Ensure.ArgumentNotNull(update, "update");
|
||||
|
||||
return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), update, AcceptHeaders.ProtectedBranchesApiPreview);
|
||||
return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), update, null, AcceptHeaders.ProtectedBranchesApiPreview);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -216,7 +216,7 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");
|
||||
Ensure.ArgumentNotNull(update, "update");
|
||||
|
||||
return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesApiPreview);
|
||||
return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null, AcceptHeaders.ProtectedBranchesApiPreview);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -35,18 +36,20 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// Status check settings for protected branch
|
||||
/// </summary>
|
||||
[SerializeNull]
|
||||
public BranchProtectionRequiredStatusChecksUpdate RequiredStatusChecks { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Push access restrictions for the protected branch
|
||||
/// </summary>
|
||||
[SerializeNull]
|
||||
public ProtectedBranchRestrictionsUpdate Restrictions { get; protected set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "StatusChecks: {0} Restrictions: {1}", RequiredStatusChecks, Restrictions);
|
||||
return String.Format(CultureInfo.InvariantCulture, "StatusChecks: {0} Restrictions: {1}", RequiredStatusChecks.DebuggerDisplay, Restrictions.DebuggerDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,7 +92,7 @@ namespace Octokit
|
||||
{
|
||||
get
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "IncludeAdmins: {0} Strict: {1} Contexts: {2}", IncludeAdmins, Strict, String.Join(",", Contexts));
|
||||
return String.Format(CultureInfo.InvariantCulture, "IncludeAdmins: {0} Strict: {1} Contexts: {2}", IncludeAdmins, Strict, Contexts == null ? "" : String.Join(",", Contexts));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,18 +117,20 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// Teams allowed to push to this branch
|
||||
/// </summary>
|
||||
[SerializeNull]
|
||||
public IReadOnlyList<string> Teams { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Users allowed to push to this branch
|
||||
/// </summary>
|
||||
[SerializeNull]
|
||||
public IReadOnlyList<string> Users { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "Teams: {0} Users: {1}", String.Join(",", Teams), String.Join(",", Users));
|
||||
return String.Format(CultureInfo.InvariantCulture, "Teams: {0} Users: {1}", Teams == null ? "" : String.Join(",", Teams), Users == null ? "" : String.Join(",", Users));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace Octokit
|
||||
{
|
||||
get
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "StatusChecks: {0} Restrictions: {1}", RequiredStatusChecks, Restrictions);
|
||||
return String.Format(CultureInfo.InvariantCulture, "StatusChecks: {0} Restrictions: {1}", RequiredStatusChecks.DebuggerDisplay, Restrictions.DebuggerDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ namespace Octokit
|
||||
{
|
||||
get
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "IncludeAdmins: {0} Strict: {1} Contexts: {2}", IncludeAdmins, Strict, String.Join(",", Contexts));
|
||||
return String.Format(CultureInfo.InvariantCulture, "IncludeAdmins: {0} Strict: {1} Contexts: {2}", IncludeAdmins, Strict, Contexts == null ? "" : String.Join(",", Contexts));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ namespace Octokit
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class ProtectedBranchRestrictions
|
||||
{
|
||||
protected ProtectedBranchRestrictions() { }
|
||||
public ProtectedBranchRestrictions() { }
|
||||
|
||||
public ProtectedBranchRestrictions(IReadOnlyList<Team> teams, IReadOnlyList<User> users)
|
||||
{
|
||||
@@ -190,7 +190,7 @@ namespace Octokit
|
||||
{
|
||||
get
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "Teams: {0} Users: {1}", Teams, Users);
|
||||
return String.Format(CultureInfo.InvariantCulture, "Teams: {0} Users: {1}", Teams == null ? "" : String.Join(",", Teams), Users == null ? "" : String.Join(",", Users));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user