This worked for me:
I. Update yourdll.fakes to include:
...
<ShimGeneration>
<Clear/>
...
<Add FullName="Models.DBModel"/>
...
</ShimGeneration>
...
II. In your TestClass create method with [TestInitialize] and [TestCleanup] attribute:
using Models.Fakes;
IDisposable shimsContext;
[TestInitialize]
public void SetUp()
{
shimsContext = ShimsContext.Create();
ShimDBModel.Constructor = (@this) =>
{
ShimDBModel shim = new ShimDBModel(@this)
{
// here you can provide shim methods for DBModel
};
};
}
[TestCleanup]
public void CleanUp()
{
// Let's do not forget to clean up shims after each test runs
shimsContext.Dispose();
}
III. And finally in your test, the Y.db should be Shim created in SetUp method.
[TestMethod]
public void Test()
{
Y.db... // db should be shim
}