I did not test this, but have you tried the following for #2?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[TestFixture]
type MyTestClass = class
  val mutable mock: Mockery
  val mutable something: ISomethingToMock
  
  member x.Setup() =
    x.mock <- new Mockery()
    x.something <- x.mock.NewMock<ISomethingToMock>()
  
  [Test]
  member x.SomeTest() =
    Expect.Once.On(something).Method("TheMethodName").With([|arg1; arg2|]) |> ignore
    ...
end

I found unit testing in F# 'okay', but current mock frameworks are not (yet!) really geared towards F# and functional languages in general. You could always write your library in F# and test it using C# or VB.NET.

[Edit]
Check out this post for info on testing functions (as opposed to classes) with xUnit.NET
[/Edit]

Regards,
Carl

By on 4/1/2008 11:30 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper