Expression> 在模拟设置 xunit .net6 中未按预期工作

Expression> is not working as expected in mock setup xunit .net6

我尝试使用 xunit 测试此方法。

public async Task<IList<DraftEntity>> Handle(GetDraftsQuery request, CancellationToken cancellationToken)
{
    var res = await _repository.GetAllAsync(a => a.CustomerIsin == _user.CustomerIsin);
    return res.Data;
}

这是我的测试代码:

  public async void GetDraftsQueryTest_when_customerISIN_is_same_draft_is_not_null()
    {
        //Arange

        IList<DraftEntity> ListOutpuddata = new List<DraftEntity>() { new DraftEntity()
        {
            CustomerIsin=customerisin,

        }

        };
       
        repo.Setup(i => i.GetAllAsync(i=>i.CustomerIsin==It.IsAny<string>())).Returns(Task.FromResult(OperationResult<IList<DraftEntity>>.Succeed(ListOutpuddata)));

     }

但是当我调试代码时,我的方法中的 res 变量为空。为什么?

最终设置

  repo.Setup(i => i.GetAllAsync(It.IsAny<Expression<Func<DraftEntity, bool>>>())).Returns(Task.FromResult(OperationResult<IList<DraftEntity>>.Succeed(ListOutpuddata)));