Moq Returns with multiple Linq Expressions

后端 未结 1 348
情深已故
情深已故 2021-01-24 07:49

I have the following method within a repository that I am trying to Mock:

IEnumerable GetAll(
      Expression> fi         


        
1条回答
  •  醉话见心
    2021-01-24 08:15

    Your GetAll method takes three arguments and returns an IEnumerable. The valueFunction parameter in Returns needs to have a matching signature and return type. The valueFunction parameter in your example only has two input arguments and the second argument does not match any of the argument types passed to GetAll. It should look something like this (I don't have the benefit of the compiler checking my syntax but I think what I have here should be correct):

    mockContactNumberRepository
    .Setup(x => 
        x
        .GetAll(
            It.IsAny>>(), 
            It.IsAny, IOrderedQueryable>>(),
            It.IsAny()))
    .Returns(new Func<
        Expression>, 
        Func, IOrderedQueryable>,
        string,
        IEnumerable>((arg1, arg2, arg3) => 
            {
                // arg1 is Expression>
                // arg2 is Func, IOrderedQueryable>
                // arg3 is string
                // Do something here and return an IEnumerable
            }));
    

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