I am using Moq to create Mocks for EQ6 async methods but something is not working right because me The following exception is found:
The source IQueryable IDbAsyncEnumerable {0} does not apply. The only sources implementing the IDBSync Enimereble can be used for the unit framework asynchronous tasks. For more information see
I have the following code:. UnitTest1.cs
on mockSet = new fake & lt; DbSet & LT; MyModel & gt; & Gt; (); MockSet.As & LT; IDbAsyncEnumerable & LT; MyModel & gt; & Gt; () .Setup (M => m.GetAsyncEnumerator ()) .Returns (New TestDbAsyncEnumerator & lt; MyModel & gt; (data.GetEnumerator ()); MockSet.As & LT; IQueryable & LT; MyModel & gt; & Gt; () .Setup (M = & gt; m.Provider) .Returns (New TestDbAsyncQueryProvider & lt; MyModel & gt; (data.Provider)); MockSet.As & lt; IQueryable & lt; MyModel & gt; & Gt; (). Setup (m = & gt; m.Expression) .Returns (data.Expression); MockSet.As & LT; IQueryable & LT; MyModel & gt; & Gt; () Setup (m = & gt; m.ElementType) .Returns (data.ElementType); MockSet.As & LT; IQueryable & LT; MyModel & gt; & Gt; () Setup (m = & gt; m.GetEnumerator ()) Returns (data.GetEnumerator ()). Var mockcontact = new fake & lt; PDBContext & gt; (); Mokkontext. Setup (C => G. Gateset ()). Return (masket object); //testing! Var Controller = New MyModelController (); Controller MyModelStore = New MyModelStore (mockcontact.Object); Var Results = Waiting for Controller OkNegotiatedContentResult as GetBestOppertunity (2) & lt; List & lt; MyModel & gt; & Gt ;; // Results Assurance. No No (result); Extraordinary (2, results. Content. Count);
MyModelStore.cs
Public async jobs & lt; List & lt; MyModel & gt; & Gt; MyModel & gt; GetBestOppertunity (integer limit) {return Context.GetSet Wait for () OrderByDescending (x => x.StartDate) .ake (border) .toListAsync (); }
I have code based on the following blog to avoid error:
But the exact error is that I am trying to stop. The error has been explained:
An error occurred in the code: GetBestOppertunity (full range) in MyModelStore.cs
The GetSet method has detected that the unit attaches to the test method There is nothing more than the cover to be able to do.
PDBContext.cs (DatabaseFirst)
Public Partial Category PDBContext: IPDBTXtex {Public Virtual IDbSet & lt; T & gt; GetSet & lt; T & gt; () Where T: class {return set & lt; T & gt; (); }}
Any thoughts that I am doing wrong?
Comments
Post a Comment