How to Mock the database with Moq
# help-with-umbraco
a
I am trying to add some unit / integration tests to my database service, I can't figure out how to mock the database I can mock the IScope but the database comes back as null. Some help would be greatly appreciated!
n
The short answer is "don't" - you can probably use the Umbraco.Cms.Test package to get access to all the core services being Moq'd the way HQ does it so you don't have to try and moq it yourself.
a
I'm trying to test against a custom table from a custom database service
b
What are you using/how are you connecting to the custom table?
a
Using Npoco via IScope
b
I've hit the actual database, integration test style before but scoped each test in the setup teardown so you can reset the state, if that makes sense? Would that work?
3 Views