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.IsReadOnlymethod to a wrapper class.EXAMPLE: For more information, see
SystemManagerWrapper.csclass in Sitefinity documentation-samples on GitHub. -
Refactor the
IsDeletionAllowedmethod.EXAMPLE: For more information, see
SutClass.csclass in Sitefinity documentation-samples on GitHub. -
Test the method by mocking the
ISystemManagerWrapperusing Telerik JustMock.EXAMPLE: For more information, see
SitefinityUnitTests.csclass in Sitefinity documentation-samples on GitHub.