How do I use Moq and DbFunctions in unit tests to prevent a NotSupportedException?

前端 未结 7 1709
借酒劲吻你
借酒劲吻你 2020-12-05 23:05

I\'m currently attempting to run some unit tests on a query that is running through the Entity Framework. The query itself runs without any issues on the live version, but t

7条回答
  •  萌比男神i
    2020-12-05 23:40

    Hmm, not sure but couldn't you do something like this?

    context.Setup(s => DbFunctions.TruncateTime(It.IsAny()))
        .Returns(new Func(
            (x) => {
                /*  whatever modification is required here */
                return x; //or return modified;
            }));
    

提交回复
热议问题