Skip to content
This repository was archived by the owner on Jul 12, 2020. It is now read-only.
This repository was archived by the owner on Jul 12, 2020. It is now read-only.

Failing on unit tests when calling ToListAsync() #128

@ssraman1977

Description

@ssraman1977

I am trying to setup a unit test for the following method I created:

---- Service Method ----
public async Task<List> GetEmployeesAsync()
{
return await _store.Query().ToListAsync());
}
-----

I setup the following using MOQ:

---- Unit Test ----
var store = new Mock<ICosmosStore>();

store.Setup(p => p.Query(null)).Returns(
new Employees[] {
new Employee() { Name = "Test Employee" }
}.AsQueryable());

var target = new EmployeeService(store.Object);
var result = await target.GetEmployeesAsync();
-------

I receive the following error when the ToListAsync() is called:

System.InvalidCastException : Unable to cast object of type 'System.Linq.EnumerableQuery1[Lcp.Domain.Entities.Employee]' to type 'Microsoft.Azure.Documents.Linq.IDocumentQuery1[Lcp.Domain.Entities.Employee]'.

How can I properly Moq this process?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions