All you need to do to get your source snippet to work is fixing f so that the signature matches TestDelegate , which is unit -> unit . Just File.GetAttributes return value of File.GetAttributes :
let f = fun () -> File.GetAttributes("non-existing.file") |> ignore
The F # compiler did not run your source code because there is only one installation of NUnit overload Assert.That(actual: obj, expression: Constraints.IResolveConstraint) .
Since Assert.That is very widely used, I would stick with a more specific statement form for checking expected exceptions, for example:
[<Test>] let foo() = Assert.Throws<FileNotFoundException> (fun () -> File.GetAttributes("non-existing.file")|> ignore) |> ignore
where the F # compiler could statically determine the incorrect signature of your function.
source share