I need to check whether my validation function returns some
thing when fails or none
. If it returns Some<string>
, there is a validation error, otherwise it's valid and the function returns None
.
This is my attempt , but it's not refactoring safe:
[<Property(Arbitrary=[| typeof<Strings.WithLenFrom1To100> |])>]
let ``lengthValidator should return some error when the string's length is longer than expected``(str:string)=
let maxValidLen = str.Length-1
let actual = lengthValidator maxValidLen str
let expected = Some(sprintf "Maximum string length is %i but %s contains %i characters" maxValidLen str str.Length)
//How can I say **let expected = Some(anything) **instead
test <@actual = expected@>
test <@ actual.IsSome @>