For developers: Maintain decoupled code
If you follow this approach, you avoid calling any static methods and program everything against an interface. Later, during the unit testing, you can mock the implementation all of the dependencies easily.
To create a unit test, use the following procedure:
- Program against interface and move the static method call of the
SystemManager.SystemServices.IsReadOnly
method to a wrapper class:
-
Refactor the
IsDeletionAllowed
method in the following way:
-
Test the method by mocking the
ISystemManagerWrapper
using Telerik JustMock in the following way: