Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
例外が起こるかもしれないparameterizeなテスト
let catch (expr: Lazy<'T>) =
try
Choice2Of2(expr.Force())
with
| ex -> Choice1Of2(ex)
let parameterizedTest(input, expected) = test {
let actual = catch (Lazy.Create <| fun () -> fut input)
match (expected, actual) with
| (Choice1Of2 ex, Choice1Of2 ex') ->
do! assertEqual (ex.GetType()) (ex'.GetType())
| (Choice2Of2 value, Choice2Of2 value') ->
do! assertEqual value value'
| _ ->
let message = sprintf "Expect: %A\nActual: %A" expected actual
do! AssertionResult.NotPassed(NotPassedCause.Violated message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.