Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqliteCreatorTest.cs =================================================================== diff -u -rd18995d638a6c3f99cb7a8419107bb4148420301 -r28ab332db2d96ad9e766f19677af1c00fc88a644 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqliteCreatorTest.cs (.../StorageSqliteCreatorTest.cs) (revision d18995d638a6c3f99cb7a8419107bb4148420301) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqliteCreatorTest.cs (.../StorageSqliteCreatorTest.cs) (revision 28ab332db2d96ad9e766f19677af1c00fc88a644) @@ -105,19 +105,16 @@ [Test] public void CreateDatabaseStructure_ValidExistingFile_ThrowsStorageException() { - string tempRingtoetsFile = TestHelper.GetScratchPadPath("tempProjectFile.rtd"); - using (new FileDisposeHelper(tempRingtoetsFile)) + string tempRingtoetsFile = TestHelper.GetScratchPadPath(nameof(CreateDatabaseStructure_ValidExistingFile_ThrowsStorageException)); + using (var disposeHelper = new FileDisposeHelper(tempRingtoetsFile)) { + disposeHelper.LockFiles(); + // Call TestDelegate call = () => StorageSqliteCreator.CreateDatabaseStructure(tempRingtoetsFile); - ArgumentException exception; - using (File.Create(tempRingtoetsFile)) // Locks file - { - exception = Assert.Throws(call); - } - // Assert + var exception = Assert.Throws(call); var expectedMessage = $@"File '{tempRingtoetsFile}' already exists."; Assert.AreEqual(expectedMessage, exception.Message); }