You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.
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?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.EnumerableQuery
1[Lcp.Domain.Entities.Employee]' to type 'Microsoft.Azure.Documents.Linq.IDocumentQuery
1[Lcp.Domain.Entities.Employee]'.How can I properly Moq this process?
The text was updated successfully, but these errors were encountered: