I am modifiying a class method which formats some input paramater dates which are subsequently used as params in a method call into the base class (which lives in another as
As of 2013 with latest Moq you can. Here is an example
public class ViewModelBase
{
public virtual bool IsValid(DateTime date)
{
//some complex shared stuff here
}
}
public class MyViewModel : ViewModelBase
{
public void Save(DateTime date)
{
if (IsValid(date))
{
//do something here
}
}
}
public void MyTest()
{
//arrange
var mockMyViewModel = new Mock(){CallBase = true};
mockMyViewModel.Setup(x => x.IsValid(It.IsAny())).Returns(true);
//act
mockMyViewModel.Object.Save();
//assert
//do your assertions here
}