This is a migrated thread and some comments may be shown as answers.

Mocking a static method in Silverlight

1 Answer 104 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Carl Rippon
Top achievements
Rank 1
Carl Rippon asked on 23 Aug 2010, 09:54 AM

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()
 
        Mock.Assert(SomeClass)
    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





1 Answer, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 24 Aug 2010, 03:24 PM
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.


Regards,
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
Tags
General Discussions
Asked by
Carl Rippon
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Share this question
or