EntityFramework 用Moles的mock
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}
TAG: