Hi! I was new to ES, and I am trying to mock a MultiSearchResponse, and I started from successfully mocking a SearchResponse
var mockSearchResponse = new Mock<ISearchResponse<CandidateSearchDto>>();
mockSearchResponse.Setup(sr => sr.Documents)
.Returns(new List<CandidateSearchDto>
{
new CandidateSearchDto(),
new CandidateSearchDto(),
new CandidateSearchDto()
});
mockSearchResponse.Setup(sr => sr.Total)
.Returns(3);
var mockMultiSearchResponse = new Mock<MultiSearchResponse>();
mockMultiSearchResponse.Setup(ms => ms.AllResponses)
.Returns(new List<IResponse> { mockSearchResponse.Object });
However, on mockMultiSearchResponse it is giving me this error:
System.NotSupportedException : Unsupported expression: ms => ms.AllResponses
Non-overridable members (here: MultiSearchResponse.get_AllResponses) may not be used in setup / verification expressions.
Is there any ways to work around this issue? I found this post
that suggests to create actual instances instead of Mock<> ones, but I am not sure how to simply initialize a MultiSearchResponse variable. Can someone help out? Thanks!!