-
-
Save jeroldhaas/c24659126f6819789f2481fdeb7f7d8e to your computer and use it in GitHub Desktop.
There, screw nunit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exception AssertionException of string | |
module Assert = | |
let isTrue value = | |
if not value then | |
raise (AssertionException "Expected true but got false.") | |
let isFalse value = | |
if value then | |
raise (AssertionException "Expected false but got true.") | |
let inline areEqual expected actual = | |
if expected <> actual then | |
raise (AssertionException ("Expected value '" + string expected + "' but got '" + string actual + "'.")) | |
let tests1 (ty : Type) = | |
let methods = ty.GetMethods (BindingFlags.Instance ||| BindingFlags.Public) | |
let instance = Activator.CreateInstance(ty, [||]) | |
for meth in methods do | |
try meth.Invoke(instance, [||]) |> ignore | |
with | |
| :? AssertionException as exn -> Console.WriteLine ("Test method '" + ty.FullName + "." + meth.Name + "' failed due to: " + string exn) | |
| exn -> Console.WriteLine ("Test method '" + ty.FullName + "." + meth.Name + "' unexpectedly exited with exception: " + string exn) | |
let tests<'t> () = | |
tests1 (typeof<'t>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment