From bf5b2f2d240a16d45481f63fbd3accb15e47e4e3 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 28 Feb 2020 17:19:41 -0400 Subject: [PATCH] a bit of tidy up --- src/Octokit.CodeGen/ApiBuilder.cs | 46 +++++++++---------- test/Octokit.CodeGen.Tests/PathFilterTests.cs | 10 ++-- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/Octokit.CodeGen/ApiBuilder.cs b/src/Octokit.CodeGen/ApiBuilder.cs index 374c9c21..798c5857 100644 --- a/src/Octokit.CodeGen/ApiBuilder.cs +++ b/src/Octokit.CodeGen/ApiBuilder.cs @@ -71,31 +71,31 @@ namespace Octokit.CodeGen return data; }; + static readonly Func convertVerbToMethodName = (verb) => + { + if (verb.Method == HttpMethod.Get) + { + // what about Get with 200 response being a list? + // this should be GetAll instead to align with our conventions? + return "Get"; + } + + if (verb.Method == HttpMethod.Delete) + { + return "Delete"; + } + + if (verb.Method == HttpMethod.Put) + { + return "GetOrCreate"; + } + + return "???"; + }; + + public static readonly TypeBuilderFunc AddMethodForEachVerb = (metadata, data) => { - Func convertVerbToMethodName = (verb) => - { - if (verb.Method == HttpMethod.Get) - { - // what about Get with 200 response being a list? - // this should be GetAll instead to align with our conventions? - return "Get"; - } - - if (verb.Method == HttpMethod.Delete) - { - return "Delete"; - } - - - if (verb.Method == HttpMethod.Put) - { - return "GetOrCreate"; - } - - return "???"; - }; - Func> convertToParameters = (verb) => { var list = new List(); diff --git a/test/Octokit.CodeGen.Tests/PathFilterTests.cs b/test/Octokit.CodeGen.Tests/PathFilterTests.cs index 358b1aa6..ea0309ea 100644 --- a/test/Octokit.CodeGen.Tests/PathFilterTests.cs +++ b/test/Octokit.CodeGen.Tests/PathFilterTests.cs @@ -5,12 +5,16 @@ namespace Octokit.CodeGen.Tests { public class PathFilterTests { + readonly PathFilter pathFilter; + + public PathFilterTests() + { + pathFilter = new PathFilter(); + } [Fact] public void Allow_WhenUnset_BlocksEverything() { - var pathFilter = new PathFilter(); - var items = new List {{ new PathMetadata() { @@ -24,8 +28,6 @@ namespace Octokit.CodeGen.Tests [Fact] public void Allow_WithPrefixMatchingPath_PassesThrough() { - var pathFilter = new PathFilter(); - pathFilter.Allow("/foo"); var items = new List {{