Completed
Last Updated: 13 Nov 2024 15:35 by ADMIN
Ivo
Created on: 13 Jun 2024 07:29
Type: Feature Request
2
Collection mock should support async queries

Collection mock (result from ReturnCollection clause) does not support async queries due to the unimplemented IAsyncQueryProvider interface. The issue could be easily reproduced with the following simple test:

[Fact]
public void ShouldReturnEntity()
{
    var db = Mock.Create<MyModel.MyModel>();
    Mock.Arrange(() => db.SomeEntities).ReturnsCollection(someEntities);

    var entity = db.SomeEntities.SingleAsync(x => x.Id == 1);

    Assert.NotNull(entity);
}

The outcome is the the following exception:

System.InvalidOperationException
The provider for the source 'IQueryable' doesn't implement 'IAsyncQueryProvider'. Only providers that implement 'IAsyncQueryProvider' can be used for Entity Framework asynchronous operations.

1 comment
ADMIN
Ivo
Posted on: 13 Nov 2024 15:35

The requested feature is available in Q4 2024 (2024.4.1113.345). Sample usage can be found here.

Regards,
Ivo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.