I am trying to write unit tests for DocumentDBRepository paging code. Since there is continuation token involved in the FeedResponse, I need to mock the FeedResponse in order to put some value for FeedResponse.ContinuationToken. But the problem is that I got an error saying:
Message: System.ArgumentException : Constructor arguments cannot be passed for interface mocks.
Does it mean I am not able to mock FeedResponse? Or maybe the way I use FeedResponse is wrong?
Here's my code:
var response = new Mock<IFeedResponse<T>>(expected);
response.Setup(_ => _.ResponseContinuation).Returns(It.IsAny<string>());
var mockDocumentQuery = new Mock<IFakeDocumentQuery<T>>();
mockDocumentQuery
.SetupSequence(_ => _.HasMoreResults)
.Returns(true)
.Returns(false);
mockDocumentQuery
.Setup(_ => _.ExecuteNextAsync<T>(It.IsAny<CancellationToken>()))
.Returns((Task<FeedResponse<T>>)response.Object);
When I debugged, the break point stops at var response = new Mock<IFeedResponse<T>>(expected); and then the error happened.