Skip to content

Commit

Permalink
Adds tryGetValue tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Jan 6, 2022
1 parent 6e6e000 commit 3439f89
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/FsToolkit.ErrorHandling.Tests/Option.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ let tryParseTests =
#endif
]

let tryGetValueTests =
testList
"Option.tryGetValue"
[
#if !FABLE_COMPILER
testCase "Can Parse int"
<| fun _ ->
let expectedValue = 3
let expectedKey = "someId"
let dictToWorkOn = dict [(expectedKey, expectedValue)]
let actual = dictToWorkOn |> Option.tryGetValue expectedKey
Expect.equal actual (Some expectedValue) "Should be some value"
#endif
]

let ofResultTests =
testList
Expand All @@ -72,4 +86,5 @@ let allTests =
"Option Tests"
[ traverseResultTests
tryParseTests
tryGetValueTests
ofResultTests ]
14 changes: 14 additions & 0 deletions tests/FsToolkit.ErrorHandling.Tests/ValueOption.fs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ let tryParseTests =
]


let tryGetValueTests =
testList
"ValueOption.tryGetValue"
[
testCase "Can Parse int"
<| fun _ ->
let expectedValue = 3
let expectedKey = "someId"
let dictToWorkOn = dict [(expectedKey, expectedValue)]
let actual = dictToWorkOn |> ValueOption.tryGetValue expectedKey
Expect.equal actual (ValueSome expectedValue) "Should be some value"
]

let ofResultTests =
testList
"ValueOption.ofResult Tests"
Expand All @@ -73,5 +86,6 @@ let allTests =
"ValueOption Tests"
[ traverseResultTests
tryParseTests
tryGetValueTests
ofResultTests ]
#endif

0 comments on commit 3439f89

Please sign in to comment.