Cannot get DbSet.Find to work with Moq (Using the Entity-Framework)

前端 未结 1 357
走了就别回头了
走了就别回头了 2021-02-01 17:01

For some reason this code keeps failing. Anyone that can tell me why:

        var activeLoans = new List {
            new ActiveLoan{
                 


        
1条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-01 18:06

    I think you need to also setup the IDbSet::Find.

    activeLoanMockSet.Setup(m => m.Find(It.IsAny()))
        .Returns(ids => activeLoans.FirstOrDefault(d => d.ID == (int)ids[0]));
    

    0 讨论(0)
提交回复
热议问题