I'm having issues trying to get NSubstitute to return an IEnumerable interface from a Task.
The factory I'm mocking:
public interface IWebApiFactory<T> : IDisposable
{
<T> GetOne(int id);
Task<IEnumerable<T>> GetAll();
Task<IEnumerable<T>> GetMany();
void SetAuth(string token);
}
The test method:
[TestMethod]
public async Task TestMutlipleUsersAsViewResult()
{
var employees = new List<EmployeeDTO>()
{
new EmployeeDTO(),
new EmployeeDTO()
};
// Arrange
var factory = Substitute.For<IWebApiFactory<EmployeeDTO>>();
factory.GetMany().Returns(Task.FromResult(employees));
}
The error I am getting is:
Error 8 Argument 2: cannot convert from 'System.Threading.Tasks.Task>' to 'System.Func>>'
Aucun commentaire:
Enregistrer un commentaire