Skip to content

Commit 8f28e1d

Browse files
author
StickFun
committed
Updated test with HttpContext check
1 parent 8517ce4 commit 8f28e1d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,10 @@ public async Task RequestDelegateHandlesNullableStringValuesFromExplicitQueryStr
688688
public async Task RequestDelegateHandlesFromFormStringArrayParameter()
689689
{
690690
var httpContext = CreateHttpContext();
691-
httpContext.Request.Form = new FormCollection(null);
691+
httpContext.Request.Form = new FormCollection(new Dictionary<string, StringValues>
692+
{
693+
["form"] = new(new[] { "1", "2", "3" })
694+
});
692695

693696
var factoryResult = RequestDelegateFactory.Create(
694697
(HttpContext context, [FromForm(Name = "form")] string[] formValues) =>
@@ -700,12 +703,7 @@ public async Task RequestDelegateHandlesFromFormStringArrayParameter()
700703

701704
await requestDelegate(httpContext);
702705

703-
var parameterBindingMetadata = factoryResult.EndpointMetadata
704-
.FirstOrDefault(e => e is ParameterBindingMetadata metadata &&
705-
metadata.Name == "formValues") as ParameterBindingMetadata;
706-
707-
Assert.NotNull(parameterBindingMetadata);
708-
Assert.Equal(typeof(string[]), parameterBindingMetadata.ParameterInfo.ParameterType);
706+
Assert.Equal(new StringValues(new[] { "1", "2", "3" }), httpContext.Items["form"]!);
709707
}
710708

711709
[Fact]

0 commit comments

Comments
 (0)