Skip to content

Commit

Permalink
PR Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Martin Peña committed Mar 28, 2022
1 parent 83fae16 commit 8dfe99e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/Acheve.TestHost/Acheve.TestHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

<ItemGroup>
<Folder Include="Routing\AttributeTemplates\" />
<Folder Include="Routing\Tokenizers\" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions src/Acheve.TestHost/HttpResponseMessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}

/// <summary>
/// Deserialize HttpResponseMessage to T Class
/// </summary>
/// <typeparam name="T">Class</typeparam>
/// <param name="responseMessage">The httpResponseMessage instance</param>
/// <returns></returns>
public static async Task<T> ReadContentAsAsync<T>(this HttpResponseMessage responseMessage)
{
var json = await responseMessage.Content.ReadAsStringAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public void AddTokens<TController>(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]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ public void AddTokens<TController>(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)
Expand All @@ -28,15 +30,15 @@ public void AddTokens<TController>(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;

if (arrayValues != null
&& arrayValues.Length != 0
)
{
var tokenName = parameters[i].Name.ToLowerInvariant();
var tokenValue = GetTokenValue(arrayValues, tokenName);
tokens.AddToken(tokenName, tokenValue, isConventional: false);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Acheve.TestHost/Routing/Tokenizers/TypeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Acheve.TestHost.Routing.Tokenizers
namespace System
{
internal static class TypeExtensions
{
Expand Down

0 comments on commit 8dfe99e

Please sign in to comment.