This question is NOT about what's here: Mocking EF DbContext with Moq and/or similar questions. I am well aware of that. Please, read the question before replying. Thanks.
We have a fairly complicated database, which has some, call them, "business objects" and some, call them, "data objects". The "business objects" are usually created or updated with every new user request and the "data objects" are fairly stable but may be occasionally created during user request if missing at the first call.
I want to create integration tests in the sand box where I could pull the data objects out of the real database (because there are too many of them to mock) but control what happens with the business objects. For example, if I have a
get or create
workflow (with some validation, of course), then I want explicitly test that whole workflow after testing separatelyget
orcreate
workflows in some other tests. However, if I testget or create
workflow, then with the real DB I can only testcreate
part of workflow once but then I will only hit aget
workflow (because the object will exist after the first test run). Throw in that many tests are routinely run in parallel and the results become unpredictable.
I wonder what is the proper approach to perform a partial "mock" of a database context where most of the tables would come from the real DB but a few tables could be setup per test, e.g. in InMemoryDbSet
s
Thanks a lot!