You can make a wrapper for the static class. I'm not familiar with DesignerProperties
class, but i've created an example below. Also look into Dependency Injection / Inversion of Control, for ease of unit testing.
The static class
static class DesignerProperties
{
public bool IsInDesigner { get; }
public void DoSomething(string arg);
// Other properties and methods
}
The interface for Dependency Injection and mocking. (You can use T4 templates for autogeneration via reflection of the static class)
interface IDesignerProperties
{
bool IsInDesigner { get; }
void DoSomething(string arg);
// mimic properties and methods from the static class here
}
The actual class for runtime usage
class DesignerPropertiesWrapper : IDesignerProperties
{
public bool IsInDesigner
{
get { return DesignerProperties.IsInDesigner; }
}
public void DoSomething(string arg)
{
DesignerProperties.DoSomething(arg);
}
// forward other properties and methods to the static class
}
Mocking class for Unit Testing
class DesignerpropertiesMock : IDesignerProperties
{
public bool IsInDesigner { get; set; } //setter accessible for Mocking
}
Usage
class ViewModel
{
private readonly IDesignerProperties _designerProperties;
// Inject the proper implementation
public ViewModel(IDesignerProperties designerProperties)
{
_designerProperties = designerProperties;
}
}
I hope this will help you.