jeudi 24 septembre 2015

Mocking methods provided by OrmLiteReadExpressionsApi

I'm using Moq so I cannot mock the extension methods that are heavily used with OrmLite.

I've got several classes that use IDbConnection and select some data our of a SQL database.

I tried just using Sqlite for the unit tests, but I am getting several failures (for obvious reasons) when trying to open a transaction. This is because the production code uses SqlServer, and I have calls to OpenTransaction(IsolationLevel.ReadUncommitted).

Reading the current release notes, it appears that the methods can now be intercepted by using OrmLiteResultsFilter. I viewed this link to see how the tests were being performed, but the tests are connecting to a database. I just want to isolate this out in my unit tests - connecting to an in-memory database, or not.

Am I stuck wrapping OrmLiteReadExpressionsApi to my own interface for the methods that I want to stub (most of the time it's Select<T>), or is there a facility that OrmLite will provider without having to configure a connection to a database (would be nice if you could set the dialect provider to MockDialectProvider or something like that).

Aucun commentaire:

Enregistrer un commentaire