Skip to content

Instantly share code, notes, and snippets.

@bryanedds
Last active July 12, 2016 16:43
Show Gist options
  • Save bryanedds/4f451af9d617e87ad1844a98e87762e7 to your computer and use it in GitHub Desktop.
Save bryanedds/4f451af9d617e87ad1844a98e87762e7 to your computer and use it in GitHub Desktop.
There, screw nunit.
exception AssertException of string
module Assert =
let isTrue value =
if not value then
raise (AssertException "Expected true but got false.")
let isFalse value =
if value then
raise (AssertException "Expected false but got true.")
let inline areEqual expected actual =
if expected <> actual then
raise (AssertException ("Expected value '" + string expected + "' but got '" + string actual + "'."))
let fixture1 (ty : Type) =
let methods = ty.GetMethods (BindingFlags.Instance ||| BindingFlags.Public)
let fixture = Activator.CreateInstance(ty, [||])
for meth in methods do
try meth.Invoke(fixture, [||]) |> ignore
with
| :? AssertException 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 fixture<'t> () =
fixture1 typeof<'t>
module Tests =
type Fixture () =
member this.Fn () =
Assert.isTrue true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment