Mocking a static method in Silverlight

2 posts, 0 answers
  1. Carl Rippon
    Carl Rippon avatar
    14 posts
    Member since:
    Mar 2010

    Posted 23 Aug 2010 Link to this post

    I’m getting the following error when trying to mock a static function in a silverlight unit test:

    “There were some problems intercepting the mock call. Optionally, please make sure that you have turned on JustMock's profiler while mocking concrete members.

    I don’t get the error in a full .NET unit test project, so, I wondered whether I was missing a setting or something?

    My code from my silverlight unit test project is below. I get the error on the Mock.Arrange() line

    Imports Microsoft.VisualStudio.TestTools.UnitTesting
    Imports Telerik.JustMock
    <TestClass()> _
    Public Class Tests
        <TestMethod()> _
        Public Sub SharedMethodMustBeCalled()
            Mock.Arrange(Function() SharedStuff.GetSomething(Arg.AnyString)).MustBeCalled()
            Dim SomeClass As New SomeClass
            Dim ret As String = SomeClass.DoSomething()
        End Sub
        Public Class SomeClass
            Public Function DoSomething() As String
                Dim ret As String = SharedStuff.GetSomething("fred")
                Return ret
            End Function
        End Class
        Public Class SharedStuff
            Public Shared Function GetSomething(ByVal Name As String) As String
                Return "test"
            End Function
        End Class
    End Class

  2. Ricky
    Ricky avatar
    467 posts

    Posted 24 Aug 2010 Link to this post

    Hello Carl,

    Unfortunately, it is not possible to mock concrete members from within Silverlight runtime that requires profiler API. However, you can still mock members that can be intercepted using a proxy like that of  virtual members or interfaces.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top