In this topic you will learn how to easily cover advanced (or elevated) testing scenarios with Telerik JustMock.
Advanced testing scenarios include:
- Mocking Sealed Classes
- Mocking Static Classes, Methods and Properties
- Mocking Final Methods and Properties
- Mocking Framework Methods (MsCorlib)
- Mocking Non-public Members and Types
- Mocking LINQ Queries
To cover these scenarios, Telerik JustMock uses the .NET Profiling API. We provide integration tools with Visual Studio
and you need to use the Enable
commands from within the Telerik JustMock menu when you
run unit tests that utilize the advanced scenarios.
Telerik JustMock supports what we call a dual architecture which basically covers the basic and the advanced(elevated) scenarios.
In "basic mode" we support mocking interfaces, virtual and abstract methods and properties. While you mock
those types you only need to reference the Telerik.JustMock.dll in your project. In this mode keep Telerik JustMock disabled
and let your unit tests run lighting fast.
When you need the advanced features, you need to go to "elevated mode", i.e. to enable Telerik JustMock from the menu.
In this mode Telerik JustMock makes use of the .NET Profiling API with a specially designed dynamic proxy library optimized
only for the mocking needs.
How to Enable/Disable Telerik JustMock?
You only need to enable Telerik JustMock when you want to use the advanced features.
To enable/disable Telerik JustMock go to the Telerik JustMock menu and select Enable/Disable
or use the shortcuts Ctrl+Alt+[ / Ctrl+Alt+] accordingly.
How to Disable Telerik JustMock programmatically?
If you are not using any of the Advanced features described in this section, you may want to ensure that Telerik JustMock is not using the profiler.
You can do this for the current test class scope by initiating a call to the Mock.DoNotUseProfiler() method.
Here is a quick example:
public void Setup()
In This Section