1
shouts

F#: Forcing type to unit for Assert.ShouldThrow in XUnit.NET - Mark Needham

posted by beebee 355 days, 17 hours, 42 minutes ago
Friday, March 27, 2009 8:42:14 PM GMT

I've started playing around with F# again and decided to try and create some unit tests around the examples I'm following from Real World Functional Programming. After reading Matt Podwysocki's blog post about XUnit.NET I decided that would probably be the best framework for me to use.

The example I'm writing tests around is:

let convertDataRow(str:string) =

let cells = List.of_seq(str.Split([|','|]))

...

I started driving that out from scratch but ran into a problem trying to assert the error case when an invalid data format is passed in.

The method to use for the assertion is 'Assert.ShouldThrow' which takes in an Assert.ThrowsDelegate which takes in an argument of type unit->unit.

category: Foundation | clicked: 0 | | source: www.markhneedham.com | show counter code
tags: F#, Functional Programming, xUnit.net

No comments yet, be the first one to post comment.

To post your comment please login or signup