Skip to content
Merged
Changes from all commits
Commits
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
40 changes: 40 additions & 0 deletions tests/SwaggerProvider.Tests/RuntimeHelpersTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,31 @@ module ToParamTests =
let result = toParam(box 42)
result |> shouldEqual "42"

[<Fact>]
let ``toParam uses ToString for int64``() =
let result = toParam(box 9876543210L)
result |> shouldEqual "9876543210"

[<Fact>]
let ``toParam uses ToString for bool true``() =
let result = toParam(box true)
result |> shouldEqual "True"

[<Fact>]
let ``toParam uses ToString for bool false``() =
let result = toParam(box false)
result |> shouldEqual "False"

[<Fact>]
let ``toParam uses ToString for float32``() =
let result = toParam(box 3.14f)
result |> shouldContainText "3.14"

[<Fact>]
let ``toParam uses ToString for double``() =
let result = toParam(box 2.718281828)
result |> shouldContainText "2.718"

[<Fact>]
let ``toParam uses ToString for strings``() =
let result = toParam(box "hello world")
Expand Down Expand Up @@ -843,6 +868,21 @@ module FormatObjectTests =
let obj = FmtArray([||])
formatObject obj |> shouldEqual "{Tags=[]}"

[<Fact>]
let ``formatObject formats array with null element as null``() =
let obj = FmtArray([| null |])
formatObject obj |> shouldEqual "{Tags=[null]}"

[<Fact>]
let ``formatObject formats array with mixed null and non-null elements``() =
let obj = FmtArray([| "a"; null; "b" |])
formatObject obj |> shouldEqual "{Tags=[a; null; b]}"

[<Fact>]
let ``formatObject formats object with no properties as empty braces``() =
let obj = System.Object()
formatObject obj |> shouldEqual "{}"

[<Fact>]
let ``formatObject sorts properties alphabetically``() =
// Age < Name alphabetically
Expand Down
Loading