Telerik® JustMock™ by Progress

Telerik JustMock enables you to mock classes/members from Silverlight assemblies. Even more, since JustMock 2013 Q2 you are no longer bound to referring your legacy Silverlight DLLs to full .NET projects to perform elevated testing. With Telerik JustMock you can mock almost everything (from interfaces, virtual and abstract methods and properties to sealed classes, non-virtual methods and properties, static classes, methods and properties, etc.) right within the Silverlight project.

As Telerik JustMock comes in two versions (Commercial vs Free Version), there are also number of possible ways to apply mocking inside/to your Silverlight tests/assemblies:

Mocking without profiler inside SL projects

This is possible with both JustMock free and the commercial versions.

In this mode you are able to mock only interfaces, virtual and abstract methods and properties. For this, you will only need to refer the "Telerik.JustMock.Silverlight" (it can be found in the JustMock root folder, under "Libraries". ex: "C:\Program Files (x86)\Telerik\JustMock\Libraries" ) assembly to your Silverlight test project.

Example: Arranging a void call that must be called

Mocking with enabled profiler inside SL projects


This feature is available only in the commercial version of Telerik JustMock.

Refer to this topic to learn more about the differences between both the commercial and free versions of Telerik JustMock.


To use elevated mocking you first need to go to elevated mode by enabling Telerik JustMock from the menu. How to Enable/Disable Telerik JustMock?

In this mode you are able to mock everything inside your Silverlight application, even sealed classes, non-virtual methods and properties, static classes, methods and properties and more.

We suggest to follow the next steps in order to set your Silverlight test project for an elevated mocking:

  1. Start by refering the "Telerik.JustMock.Silverlight" assembly to the test project. It can be found in the JustMock root folder, under "Libraries". ex: "C:\Program Files (x86)\Telerik\JustMock\Libraries"
  2. Then, you will have to make some more configurations to your test project. There are several options:

    • (Recommended) Having your test project set as a startup project of the whole solution, we also recommend to enable its execution out of browser:

      Silverlight Mocking Enable RunningOOB

      If the above is completed, you might also need to set your test project start action to "Out-of-browser application":

      Silverlight Mocking Set Start Action

    • If you don`t want to run your test application out of browser, then you will need to take additional steps to run the application in-browser.

      • Internet Explorer 6 - no additional steps necessary

      • Internet Explorer 7 and above - Protected Mode must be disabled. Either disable it for the Internet security zone or run your test application in the Intranet security zone.

      • Any other browser - you will have to manually terminate all browser instances right before test execution.

    • Another option is to execute your test via the command prompt with the JustMockRunner, just as described here.

  3. After everything is set, you can start writting elevated tests for your Silverlight application.

Example: Removing dependency with faking HtmlDocument

Example: Faking MsCorlib DateTime.Now property

Testing Silverlight assemblies in full .NET projects

If your Silverlight application or class library is in a full .NET solution you could easily test it with Telerik JustMock. To achieve this, simply follow the next steps:

  1. Start by adding new "JustMock Test Project" to the solution.
  2. Replace the existing references with their Silverlight versions.

    For example:

    "System.DLL" should be replaced with the "System.DLL", in most cases coming from "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0\System.dll".

    You can also replace the "Microsoft.VisualStudio.QualityTools.UnitTestFramework" with any other testing framework, like NUnit or MbUnit.

  3. Further, you should add a reference to the Silverlight project, you will be testing.
  4. Finally, you are ready to start writting unit tests against your Silverlight application or class library.

See Also