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

前端 未结 1 356
走了就别回头了
走了就别回头了 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<object[]>()))
        .Returns<object[]>(ids => activeLoans.FirstOrDefault(d => d.ID == (int)ids[0]));
    
    0 讨论(0)
提交回复
热议问题