EntityFramework 用Moles的mock

Notice: 当constructor为private的时候,new MXxxxxxx().Instance , 否则就可以直接new, 但要moles constructor


using
System.Data.Objects.Moles; public void GetProjectInfoTest() { MXTRACHoldingDBEntities.AllInstances.GetProjectSettingString = (obj, fileName) => { MObjectResult01<ProjectInfo> result = new MObjectResult01<ProjectInfo>(); result.Bind( new List<ProjectInfo>() { new ProjectInfo() { ProjectName = "Project", ProjectDescription = "Description", //other properties } }); return result.Instance; }; //other codes and Assert }
posted @ 2012-10-11 14:12  霄霄  阅读(222)  评论(0编辑  收藏  举报