Created
July 12, 2016 16:35
-
-
Save bryanedds/5c031b212a63622d6ddb140b4b01f548 to your computer and use it in GitHub Desktop.
There, fuck 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