Entity framework 如何使用模拟DbContext测试延迟加载的实体?
我使用的是假的DbContext 一切正常,但是我使用的是“代码优先”的方法,并且一些测试中的代码依赖于相关实体的延迟加载Entity framework 如何使用模拟DbContext测试延迟加载的实体?,entity-framework,unit-testing,mocking,dbcontext,Entity Framework,Unit Testing,Mocking,Dbcontext,我使用的是假的DbContext 一切正常,但是我使用的是“代码优先”的方法,并且一些测试中的代码依赖于相关实体的延迟加载 public partial class Entity { public int EntityId { get; set; } public string EntityName { get; set; } public virtual ICollection<EntityLifeCycle> EntityLifeCycles { get
public partial class Entity
{
public int EntityId { get; set; }
public string EntityName { get; set; }
public virtual ICollection<EntityLifeCycle> EntityLifeCycles { get; set; }
public virtual EntityStatus PreviousStatus { get; set; }
public virtual EntityStatus CurrentStatus { get; set; }
}
如何修改我的测试代码(而不是正在测试的代码)以适应这种情况
研究链接供参考:
if (entity.EntityLifeCycles.Count() > 0)
{
...
}