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.
EXAMPLE: For more information, see SystemManagerWrapper.cs
class in Sitefinity documentation-samples on GitHub.
- Refactor the
IsDeletionAllowed
method.
EXAMPLE: For more information, see SutClass.cs
class in Sitefinity documentation-samples on GitHub.
- Test the method by mocking the
ISystemManagerWrapper
using Telerik JustMock.
EXAMPLE: For more information, see SitefinityUnitTests.cs
class in Sitefinity documentation-samples on GitHub.