I have a ViewModel class like this
public class MyViewModel : ViewModelBase
{
public MyViewModel()
{
if (!IsInDesignMode)
{
throw new InvalidOperationException();
}
}
public MyViewModel(IDataProvider dataProvider)
{
Data = new ObservableCollection<IData>(dataProvider.GetData());
}
public ObservableCollection<IData> Data { get; private set; }
}
Now I want to create some design time data. In my unit tests I am using a mocking framework (Moq) to do this. I don't like the fact that I need to create some Mock implementation of IData in my App project or referencing and using the Mocking framework.
What is the most elegant way to achieve having design time data in such a scenario?
Edit: Not sure if it is relevant but I am using Visual Studio 2012.
Basically you create a stub, not a mock for design time data. The stub can't have any dependencies injected.
Then use it in XAML like this: