Closed kornakar closed 6 years ago
I found a partial answer to this. The line
ExpandString = (s) => GetDataServiceQuery(default(T)),
should be
ExpandString = (s) => GetDataServiceQuery(data),
so that the Expand lambda can make the query and return the correct data for nested models.
I still think this is way too difficult. So any suggestions on how to improve the testing experience?
I would also like some information regarding this.
I couldn't find any documentation on how to use the library in unit tests. My case is related to using the code generated with the ODataT4CodeGenerator.tt. The generated code doesn't have any interfaces and most of the constructors are internal, so the only way to use it in unit tests seems to be using Microsoft Fakes library.
But even with the MS Fakes making everything work seems pretty complicated. Is it possible that you could provide some documentation on how we should use the generated code classes when unit testing code?
Assemblies affected
7.4.4.20330
Additional detail
I've found a way to mock some of the IQueryable methods in the main class (System, DataServiceContext) like this:
This works with simple queries, but if I add some more complexity, say an Expand operator, then everything breaks down because I have no idea what to mock or fake any more.
Example that works without the Expand lambda:
With some documentation I think the library would be much more usable in unit tests.