Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
651326a
If the method is abstract and virtual is a correct method (#72)
Sergio1192 Aug 2, 2022
f65be9c
Fix enumerable parameter (#74)
Sergio1192 Sep 13, 2022
f817b67
Add RemoveQueryParameter extension method (#75)
Sergio1192 Sep 15, 2022
c2f870d
CancellationTOken always is a query paramater (#76)
Sergio1192 Sep 21, 2022
706ab47
Version 3.4.0 (#77)
Sergio1192 Sep 21, 2022
387b500
Action convection name (#79)
Sergio1192 Oct 4, 2022
d169c53
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 Feb 22, 2023
994cb8f
Create get request when it has an object with some list
Sergio1192 Feb 22, 2023
29ab302
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 Feb 22, 2023
99f0c8a
DateTime as a primitive type but using custom formatter (#81)
Sergio1192 Mar 1, 2023
060a58c
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 Mar 1, 2023
ed138ab
Fixing codeQL alerts (#82)
Sergio1192 Mar 12, 2023
a85bb25
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 Mar 12, 2023
de91f82
feature: Get url (#83)
Sergio1192 Mar 19, 2023
35fa8de
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 Mar 20, 2023
15ea0b2
In IncludeContentAsFormUrlEncoded and PrimitiveParameterActionTokeniz…
Sergio1192 May 20, 2023
2563705
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 May 20, 2023
e204431
Add new CreateHttpApiRequest with TActionResponse (#85)
Sergio1192 May 20, 2023
026d100
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 May 20, 2023
92af8db
Add net7.0 Target Version (#86)
Sergio1192 May 20, 2023
ec294cc
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 May 20, 2023
85a2b9c
ReadContentAsAsync allows string type (#87)
Sergio1192 May 21, 2023
e6d41cc
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 May 21, 2023
e18e22f
Allow send a IFormFile (#88)
Sergio1192 May 22, 2023
d035170
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 May 22, 2023
d5aa032
Update version to 3.5.0 (#89)
Sergio1192 May 22, 2023
5b4e075
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 May 22, 2023
2018abc
Add DateTimeOffset to IsDateTime function (#91)
Sergio1192 May 22, 2023
fb8e0f3
Merge branch 'develop' of https://github.com/Xabaril/Acheve.TestHost …
Sergio1192 May 22, 2023
0f613c2
Allow dispatch workflows manually
Sergio1192 May 25, 2023
316d22c
Update to Net8 (#92)
Sergio1192 May 3, 2024
afb09ea
Different froms in object (#93)
Sergio1192 May 13, 2024
97f4d69
Version 4.0.0 (#94)
Sergio1192 May 13, 2024
a4fc44a
Merge with master
Sergio1192 May 14, 2024
d2fef41
Fix IsDateTime (#96)
Sergio1192 May 14, 2024
df4b701
Send ContentType and ContentDisposition (#98)
Sergio1192 Jun 11, 2024
adf9320
Merge with master
Sergio1192 Jun 11, 2024
1ac0440
Enum in FromQuery and FromRoute (#99)
Sergio1192 Aug 13, 2024
7f4ab58
Version 4.1.0 (#100)
Sergio1192 Nov 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
dotnet-version: |
6.0.421
7.0.408
8.0.204
8.0.415
9.0.306

- name: Build
run: dotnet build -c $BUILD_CONFIG
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
dotnet-version: |
6.0.421
7.0.408
8.0.204
8.0.415
9.0.306
- name: Build
run: dotnet build -c $BUILD_CONFIG
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project>
<PropertyGroup Label="SDK Versions">
<NetCoreTargetVersion>net6.0;net7.0;net8.0</NetCoreTargetVersion>
<NetCoreTargetVersion>net6.0;net7.0;net8.0;net9.0</NetCoreTargetVersion>
<LangVersion>latest</LangVersion>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<PropertyGroup Label="Package information">
<Version>4.0.0</Version>
<Version>4.1.0</Version>

<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>http://github.com/xabaril/Acheve.TestHost</PackageProjectUrl>
Expand Down
28 changes: 19 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
<Project>
<PropertyGroup Label=".Net version" Condition=" '$(TargetFramework)' == 'net6.0' ">
<NetCoreVersion>6.0.29</NetCoreVersion>
<NetCoreVersion>6.0.36</NetCoreVersion>
<MicrosoftNETTestSdkVersion>17.9.0</MicrosoftNETTestSdkVersion>
<XUnitRunnerVisualStudioVersion>2.8.2</XUnitRunnerVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Label=".Net version" Condition=" '$(TargetFramework)' == 'net7.0' ">
<NetCoreVersion>7.0.18</NetCoreVersion>
<NetCoreVersion>7.0.20</NetCoreVersion>
<MicrosoftNETTestSdkVersion>17.9.0</MicrosoftNETTestSdkVersion>
<XUnitRunnerVisualStudioVersion>2.8.2</XUnitRunnerVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Label=".Net version" Condition=" '$(TargetFramework)' == 'net8.0' ">
<NetCoreVersion>8.0.4</NetCoreVersion>
<NetCoreVersion>8.0.21</NetCoreVersion>
<MicrosoftNETTestSdkVersion>18.0.0</MicrosoftNETTestSdkVersion>
<XUnitRunnerVisualStudioVersion>3.1.5</XUnitRunnerVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Label=".Net version" Condition=" '$(TargetFramework)' == 'net9.0' ">
<NetCoreVersion>9.0.10</NetCoreVersion>
<MicrosoftNETTestSdkVersion>18.0.0</MicrosoftNETTestSdkVersion>
<XUnitRunnerVisualStudioVersion>3.1.5</XUnitRunnerVisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="General Dependencies">
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="$(NetCoreVersion)" />
</ItemGroup>
<ItemGroup Label="Sample Dependencies">
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(NetCoreVersion)" />
</ItemGroup>
<ItemGroup Label="Testing Dependencies">
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(NetCoreVersion)" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="xunit" Version="2.8.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
<PackageVersion Include="FluentAssertions" Version="[7.2.0]" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioVersion)" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
</ItemGroup>
<ItemGroup Label="Github Dependencies">
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"projects": ["src", "test", "samples"],
"sdk": {
"version": "8.0.000",
"version": "9.0.0",
"rollForward": "latestMajor"
}
}
1 change: 0 additions & 1 deletion samples/Sample.Api/ApiConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
//using Newtonsoft.Json;
using System.Security.Claims;

namespace Sample.Api
Expand Down
3 changes: 2 additions & 1 deletion src/Acheve.TestHost/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ internal static bool IsPrimitiveType(this Type typeToInspect)
|| type == typeof(string)
|| type == typeof(decimal)
|| type == typeof(Guid)
|| type.IsDateTime();
|| type.IsDateTime()
|| type.IsEnum;
}

internal static bool IsDateTime(this Type typeToInspect)
Expand Down
4 changes: 3 additions & 1 deletion src/Acheve.TestHost/Routing/UriDiscover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,11 @@
throw new InvalidOperationException($"The action selector is not a valid lambda expression");
}

var methodCall = (MethodCallExpression)actionSelector.Body;
var methodCall = actionSelector.Body as MethodCallExpression;
if (methodCall is null)
methodCall = (actionSelector.Body as UnaryExpression).Operand as MethodCallExpression;

var action = new TestServerAction(methodCall.Method);

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
methodCall
may be null at this access because of
this
assignment.
bool haveAttributeApiController = typeof(TController).GetTypeInfo().GetCustomAttribute(typeof(ApiControllerAttribute)) != null;
bool isGetOrDelete = action.MethodInfo.GetCustomAttributes().FirstOrDefault(attr => attr.GetType() == typeof(HttpGetAttribute)
|| attr.GetType() == typeof(HttpDeleteAttribute)) != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,12 @@ public ActionResult<ParamWithDifferentFroms> PostWithDifferentFroms(ParamWithDif
[HttpPut($"{nameof(PutWithDifferentFroms)}/{{{nameof(ParamWithDifferentFroms.ParamFromRoute)}}}")]
public ActionResult<ParamWithDifferentFroms> PutWithDifferentFroms(ParamWithDifferentFroms request)
=> Ok(request);

[HttpGet($"{nameof(GetWithEnumInRoute)}/{{request}}")]
public string GetWithEnumInRoute([FromRoute] SampleEnumeration request)
=> request.ToString();

[HttpGet($"{nameof(GetWithEnumInQuery)}")]
public string GetWithEnumInQuery([FromQuery] SampleEnumeration request)
=> request.ToString();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace UnitTests.Acheve.TestHost.Routing.Models;

public enum SampleEnumeration
{
Value1,
Value2,
Value3
}
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,40 @@ public async Task Create_put_request_with_object_with_different_froms()
content.ParamFromBody.Should().Be(model.ParamFromBody);
}

[Fact]
public async Task Create_get_request_with_enum_from_query()
{
var server = new TestServerBuilder()
.UseDefaultStartup()
.Build();

var enumValue = SampleEnumeration.Value3;

var request = server.CreateHttpApiRequest<ValuesV5Controller>(controller => controller.GetWithEnumInQuery(enumValue));
var responseMessage = await request.GetAsync();

await responseMessage.IsSuccessStatusCodeOrThrow();
var response = await responseMessage.Content.ReadAsStringAsync();
response.Should().Be(enumValue.ToString());
}

[Fact]
public async Task Create_get_request_with_enum_from_route()
{
var server = new TestServerBuilder()
.UseDefaultStartup()
.Build();

var enumValue = SampleEnumeration.Value3;

var request = server.CreateHttpApiRequest<ValuesV5Controller>(controller => controller.GetWithEnumInRoute(enumValue));
var responseMessage = await request.GetAsync();

await responseMessage.IsSuccessStatusCodeOrThrow();
var response = await responseMessage.Content.ReadAsStringAsync();
response.Should().Be(enumValue.ToString());
}

private class PrivateNonControllerClass
{
public int SomeAction()
Expand Down
Loading