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:

  1. Program against interface and move the static method call of the SystemManager.SystemServices.IsReadOnly method to a wrapper class.

    EXAMPLE: For more information, see SystemManagerWrapper.cs class in Sitefinity documentation-samples on GitHub.

  2. Refactor the IsDeletionAllowed method.

    EXAMPLE: For more information, see SutClass.cs class in Sitefinity documentation-samples on GitHub.

  3. Test the method by mocking the ISystemManagerWrapper using Telerik JustMock.

    EXAMPLE: For more information, see SitefinityUnitTests.cs class in Sitefinity documentation-samples on GitHub.

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?

Next article

Use advanced mocking