public class DtoUser : Base.DtoBase {
public string Name { get; set; }
public string id{ get; set ; }
}
[TestMethod()] [AspNetDevelopmentServerHost("E:\\程序测试\\ASPNetMVC\\MVCTest\\MVCTest.Web", "/")] public void Index_adf_Test() { DtoStudentExp studentParam = new DtoStudentExp;
List<DtoUser > listUser= new List<DtoUser >();
adf.Add(new DtoStudent() { Id = 1, Name = "adf"}); adf.Add(new DtoStudent() { Id = 2, Name = "adf" });
PagedList<DtoStudent> dd1 = new PagedList<DtoStudent>(listUser, 1, 10);
Mock<IStudent> mockIStudent = new Mock<IStudent>(); mockIStudent.Setup(a => a.GetList(ref studentParam)).Returns(dd1);
}
刚开始以为是 PagedList<DtoStudent>这个吴旗娃分页插件有干扰,后来去掉了这个分页,改成了
mockIStudent.Setup(a => a.GetList1(ref studentParam)).Returns(listUser)
返回依然是null
我就郁闷了,请求大牛们指点一下,究竟是moq不能模拟并返回list,还是说我的方法不对
谢谢大牛
返回null的原因一般是你mock的函数参数不对应, mock你用了ref, 调用的时候是不是用了ref