From 8dfe99e18d9714107ba3efdffcbb7a5f3c8f9e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20Martin=20Pe=C3=B1a?= Date: Mon, 28 Mar 2022 09:24:56 +0200 Subject: [PATCH] PR Comments --- src/Acheve.TestHost/Acheve.TestHost.csproj | 1 - src/Acheve.TestHost/HttpResponseMessageExtensions.cs | 6 ++++++ .../Routing/Tokenizers/ComplexParameterActionTokenizer.cs | 1 - .../Tokenizers/PrimitiveParameterActionTokenizer.cs | 8 +++++--- src/Acheve.TestHost/Routing/Tokenizers/TypeExtensions.cs | 4 +--- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Acheve.TestHost/Acheve.TestHost.csproj b/src/Acheve.TestHost/Acheve.TestHost.csproj index 7eace34..eb4ab56 100644 --- a/src/Acheve.TestHost/Acheve.TestHost.csproj +++ b/src/Acheve.TestHost/Acheve.TestHost.csproj @@ -15,7 +15,6 @@ - diff --git a/src/Acheve.TestHost/HttpResponseMessageExtensions.cs b/src/Acheve.TestHost/HttpResponseMessageExtensions.cs index b7078a4..b5702ee 100644 --- a/src/Acheve.TestHost/HttpResponseMessageExtensions.cs +++ b/src/Acheve.TestHost/HttpResponseMessageExtensions.cs @@ -22,6 +22,12 @@ public static async Task IsSuccessStatusCodeOrThrow(this HttpResponseMessage res throw new Exception($"Response status does not indicate success: {response.StatusCode:D} ({response.StatusCode}); \r\n{content}"); } + /// + /// Deserialize HttpResponseMessage to T Class + /// + /// Class + /// The httpResponseMessage instance + /// public static async Task ReadContentAsAsync(this HttpResponseMessage responseMessage) { var json = await responseMessage.Content.ReadAsStringAsync(); diff --git a/src/Acheve.TestHost/Routing/Tokenizers/ComplexParameterActionTokenizer.cs b/src/Acheve.TestHost/Routing/Tokenizers/ComplexParameterActionTokenizer.cs index 683e365..2612011 100644 --- a/src/Acheve.TestHost/Routing/Tokenizers/ComplexParameterActionTokenizer.cs +++ b/src/Acheve.TestHost/Routing/Tokenizers/ComplexParameterActionTokenizer.cs @@ -18,7 +18,6 @@ public void AddTokens(TestServerAction action, TestServerTokenColle var type = parameters[i].ParameterType; var instance = action.ArgumentValues.Any(x => x.Key == i) ? action.ArgumentValues[i].Instance : null; - if (instance != null && !type.IsPrimitiveType()) { if (!IgnoreBind(parameters[i])) diff --git a/src/Acheve.TestHost/Routing/Tokenizers/PrimitiveParameterActionTokenizer.cs b/src/Acheve.TestHost/Routing/Tokenizers/PrimitiveParameterActionTokenizer.cs index 1160820..962a9ac 100644 --- a/src/Acheve.TestHost/Routing/Tokenizers/PrimitiveParameterActionTokenizer.cs +++ b/src/Acheve.TestHost/Routing/Tokenizers/PrimitiveParameterActionTokenizer.cs @@ -16,10 +16,12 @@ public void AddTokens(TestServerAction action, TestServerTokenColle for (var i = 0; i < parameters.Length; i++) { + var tokenName = parameters[i].Name.ToLowerInvariant(); + if (parameters[i].ParameterType.IsPrimitiveType() && !IgnoreHeader(parameters[i])) { - var tokenName = parameters[i].Name.ToLowerInvariant(); + var tokenValue = action.ArgumentValues.Any(x => x.Key == i) ? action.ArgumentValues[i].Instance : null; if (tokenValue != null) @@ -28,7 +30,8 @@ public void AddTokens(TestServerAction action, TestServerTokenColle } } else if (parameters[i].ParameterType.IsArray - && IsPrimitiveType(parameters[i].ParameterType.GetElementType())) + && IsPrimitiveType(parameters[i].ParameterType.GetElementType()) + && !IgnoreHeader(parameters[i])) { var arrayValues = (Array)action.ArgumentValues[i].Instance; @@ -36,7 +39,6 @@ public void AddTokens(TestServerAction action, TestServerTokenColle && arrayValues.Length != 0 ) { - var tokenName = parameters[i].Name.ToLowerInvariant(); var tokenValue = GetTokenValue(arrayValues, tokenName); tokens.AddToken(tokenName, tokenValue, isConventional: false); } diff --git a/src/Acheve.TestHost/Routing/Tokenizers/TypeExtensions.cs b/src/Acheve.TestHost/Routing/Tokenizers/TypeExtensions.cs index 1813f54..e45adf5 100644 --- a/src/Acheve.TestHost/Routing/Tokenizers/TypeExtensions.cs +++ b/src/Acheve.TestHost/Routing/Tokenizers/TypeExtensions.cs @@ -1,6 +1,4 @@ -using System; - -namespace Acheve.TestHost.Routing.Tokenizers +namespace System { internal static class TypeExtensions {