I got this:
private List<NameValuePair<CarTemplateType>> m_tempCars
public IList<NameValuePair<CarTemplateType>> CarTypes
{
get
{
if (m_tempCars == null)
{
//somelogic
}
return m_tempCars;
}
}
CarsVM has Init where m_tempCars is being setup:
m_tempCars= CarTypes.FirstOrDefault(x => x.Value == my_data.CarTypes);
Now I have TestMethod:
[TestMethod]
Public void SomeTest()
{
CarsVM cars = new CarsVM ();
cars.CarTypes = ??? //
...
}
How to somehow Mock/Set this?
If you use Moq:
You can generally make your code more testable by following SOLID principles. They will ensure that your code modules stay small, and easy to test and extend.