Lead Product Evangelist @Kentico, Founding partner @craftbrewingbiz. love to learn / teach web dev & software engineering, collecting vinyl records, mowing my lawn, craft 🍺
The methods on ObjectQueryBase<T> are virtual, so assuming you somehow mock that, you should be able to override the methods.
The new Get() methods on IInfoProvider<T> are also virtual, so by mocking those and having them return a mocked ObjectQuery<T> (which inherits ObjectQueryBase<T>) you should be able to fake out the whole data access layer.
That said, I don't often see this kind of code being mocked because the internals of the querying code are very specific to getting data out of the database, and this seems like a much better opportunity for integration tests.
By putting code that interacts with DocumentQuery<T> and ObjectQuery<T> behind abstractions you can unit test your business logic, and integration test your data access implementation.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Lee,
The methods on
ObjectQueryBase<T>
are virtual, so assuming you somehow mock that, you should be able to override the methods.The new
Get()
methods onIInfoProvider<T>
are also virtual, so by mocking those and having them return a mockedObjectQuery<T>
(which inheritsObjectQueryBase<T>
) you should be able to fake out the whole data access layer.That said, I don't often see this kind of code being mocked because the internals of the querying code are very specific to getting data out of the database, and this seems like a much better opportunity for integration tests.
By putting code that interacts with
DocumentQuery<T>
andObjectQuery<T>
behind abstractions you can unit test your business logic, and integration test your data access implementation.