Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Binder value API is not case-insensitive #8

Closed
pimbrouwers opened this issue Apr 7, 2020 · 0 comments · Fixed by #9
Closed

Model Binder value API is not case-insensitive #8

pimbrouwers opened this issue Apr 7, 2020 · 0 comments · Fixed by #9
Assignees
Labels
bug Something isn't working

Comments

@pimbrouwers
Copy link
Owner

pimbrouwers commented Apr 7, 2020

Consider:

[<Fact>]
let ``StringCollectionReader value lookups are case-insensitive`` () =
    let values = 
        [ 
            "FString", [|"John Doe"; "Jane Doe"|] |> StringValues                
        ]
        |> Map.ofList
        |> fun m -> Dictionary(m)

    let scr = StringCollectionReader(values)

    // single values
    scr.TryGet "FSTRING"   |> Option.iter (should equal "John Doe")
    scr.TryGet "FString"   |> Option.iter (should equal "John Doe")
    scr.TryGet "fstriNG"   |> Option.iter (should equal "John Doe")
    scr?FSTRING.AsString() |> should equal "John Doe"
    scr?FString.AsString() |> should equal "John Doe"
    scr?fstrINg.AsString() |> should equal "John Doe"

    // arrays
    scr.TryArrayString "FSTRING" |> Option.iter (should equal [|"John Doe";"Jane Doe"|])
    scr.TryArrayString "fString" |> Option.iter (should equal [|"John Doe";"Jane Doe"|])
    scr.TryArrayString "fstriNG" |> Option.iter (should equal [|"John Doe";"Jane Doe"|])
    scr?FSTRING.AsArrayString()  |> should equal [|"John Doe";"Jane Doe"|]
    scr?fString.AsArrayString()  |> should equal [|"John Doe";"Jane Doe"|]
    scr?fstriNG.AsArrayString()  |> should equal [|"John Doe";"Jane Doe"|]
@pimbrouwers pimbrouwers added the bug Something isn't working label Apr 7, 2020
@pimbrouwers pimbrouwers self-assigned this Apr 7, 2020
@pimbrouwers pimbrouwers linked a pull request Apr 7, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant