Mocking an IAsyncEnumerable result from a DbSet using NSubstitute does not work and instead yield an empty result set.
A fix for this exact same issue was adressed in #25 but only for the Moq library.
Same override should be applied when using NSubstitute.
The following code snipped should return all users from a DbSet
List<UserEntity> users = new List<UserEntity> { new UserEntity() };
DbSet<UserEntity> mockDbSet = users.AsQueryable().BuildMockDbSet();
dbContext.Users.Returns(mockDbSet);
List<UserEntity> result = await userRepository.GetAllUsersAsync().ToListAsync(cancellationToken);
Assert.AreEqual(users.Count, result.Count);
Mocking an
IAsyncEnumerable
result from aDbSet
using NSubstitute does not work and instead yield an empty result set. A fix for this exact same issue was adressed in #25 but only for the Moq library. Same override should be applied when using NSubstitute.The following code snipped should return all users from a DbSet
Instead, an empty collection is returned.