模拟实体框架模型

时间:2018-11-27 17:40:56

标签: testing mocking asp.net-web-api2 entity-framework-core fakeiteasy

我想伪造我的复杂对象(具有5个对象属性的对象)以测试控制器中的post方法。

当我使用FakeItEasy时,会得到null s个对象,并且无法将该对象插入DbContext。

那么我该如何伪造呢?手动?

Debuging my test

我的计算机DTO:

public class Computer
{
    public long Id { get; set; }
    public Processor processor { get; set; }
    public ICollection<Memory> memories { get; set; }
    public ICollection<Disk> disks { get; set; }
    public MotherBoard motherBoard { get; set; }
    public ICollection<GPU> gpus { get; set; }
}

0 个答案:

没有答案