Is there a way to create a mock object and only mock one of the Property, and let the others (Properties and Methods) links to the original class, without having to mock all the methods
Test Method -->
var test= new Mock<Test>().As<ITest>();
test.CallBase = true;
test.SetupGet(m => m.DateNow).Returns(DateTime.Now.AddDays(10));
double num= test.Object.Calc();
Interface -->
public interface ITest
{
double Calc();
DateTime DateNow { get; }
}
Class -->
public class Test : ITest
{
public DateTime DateNow
{
get
{
return DateTime.Now.Date;
}
}
public double Calc(){
DateTime d = DateTime.Now.AddDays(100);
return (DateNow - d).TotalDays;
}
Always num = 0.0;