I use Fluent NHibernate to run in-memory database tests (MS Test) using SQLite 1.0.66.0:
[TestClass] public abstract class InMemoryDatabaseTest { private NHibernate.Cfg.Configuration configuration; private ISessionFactory sessionFactory; [TestInitialize] public void Initialize() {
And then, using this as an example:
[TestClass] public class MessagesControllerTests : InMemoryDatabaseTest { [TestMethod] public void SQLite_should_have_all_handles_released() { using (var session = this.CreateSession()) {
After running this test, I will try to run Clean whole solution. The results are as follows:
- With this test (CTRL + R, CTRL + T), the cleanup may succeed as expected.
- When debugging this test in (CTRL + R, T), the cleaning fails with the error:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3607,9): warning MSB3061: Unable to delete file "PathToProject\bin\Debug\System.Data.SQLite.DLL". Access to the path 'PathToProject\bin\Debug\System.Data.SQLite.DLL' is denied. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3607,9): warning MSB3061: Unable to delete file "PathToProject\bin\Debug\System.Data.SQLite.DLL". Access to the path 'PathToProject\bin\Debug\System.Data.SQLite.DLL' is denied.
My first thought was fine, remove the dll. When I try, I will be prompted that QTAgent32.exe is currently using the DLL. To verify this, I used Process Explorer. For some reason, the ms test runner stores a DLL handle. I tried modifying Cleanup metehod with some suggestions from another question , but it still didn't work:
[TestCleanup] public void Cleanup() { new SchemaExport(this.configuration).Drop(false, true); sessionFactory.Close(); sessionFactory.Dispose(); SQLiteConnection.ClearAllPools(); GC.Collect(); }
I was able to reproduce this on three different machines. Any known method of solving this problem would be very helpful.
Update . I cleared the linguistic confusion. The actual solution configuration may be in Debug / Relase. However, running tests and debugging tests causes a difference in error messages.
source share