It is not appropriate to unit test Modules and Shared methods (static classes and methods in C#) with a mocking framework because:
- Modules (static classes in C#) cannot:
- inherit from base classes
- implement interfaces
- and thus, be mocked
- Shared methods (static methods in C#) in mocked instances cannot be called
So, to unit test a Module or a class with Shared methods you need to do so directly. Example: (Unit test attributes omitted...)
Public Class A
Public Shared Function Go(a As Integer) As Integer
Return a + 10
End Function
End Class
Public Class TestClass
Public Sub Test()
Assert.AreEqual(A.Go(5), 15)
End Sub
End Class