We are using Azure cosmos client V3. For fetching data we are using GetItemLinqQueryable and ToFeedIterator for making it Async. It works well however while mocking/unit testing we are getting error related to ToFeedIterator
Code:
IOrderedQueryable<T> linqQueryable = _container.GetItemLinqQueryable<T>(requestOptions: requestOptions);
var feedIterator = linqQueryable.Where(predicate).ToFeedIterator();
For mocking UnitTestCode Code:
var _mockResponse = new Mock<ItemResponse<Test>>();
mockContainer.Setup(x => x.GetItemLinqQueryable<Test>(It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<QueryRequestOptions>())).Returns(queryable);
It does return 1 records from GetItemLinqQueryable however ToFeedIterator() fails saying System.ArgumentOutOfRangeException: 'ToFeedIterator is only supported on cosmos LINQ query operations Parameter name: linqQuery'
I ran into this same issue. Check out the comments in this github issue 893 in the azure-cosmos-dotnet-v3 repo. I ended up following approach suggested here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With