Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Core.Test/RingtoetsDatabaseFileTest.cs =================================================================== diff -u -r9d68a734d8da9bfadd3bdd349ddb56fb70d461ec -r28ab332db2d96ad9e766f19677af1c00fc88a644 --- Application/Ringtoets/test/Application.Ringtoets.Migration.Core.Test/RingtoetsDatabaseFileTest.cs (.../RingtoetsDatabaseFileTest.cs) (revision 9d68a734d8da9bfadd3bdd349ddb56fb70d461ec) +++ Application/Ringtoets/test/Application.Ringtoets.Migration.Core.Test/RingtoetsDatabaseFileTest.cs (.../RingtoetsDatabaseFileTest.cs) (revision 28ab332db2d96ad9e766f19677af1c00fc88a644) @@ -51,29 +51,21 @@ public void Constructor_FileNotWritable_ThrowsArgumentException() { // Setup - string filename = Path.GetRandomFileName(); - string filePath = TestHelper.GetScratchPadPath(filename); + string filePath = TestHelper.GetScratchPadPath($"{nameof(RingtoetsDatabaseFileTest)}.{nameof(Constructor_FileNotWritable_ThrowsArgumentException)}"); - using (new FileDisposeHelper(filePath)) + using (var helper = new FileDisposeHelper(filePath)) { - FileAttributes attributes = File.GetAttributes(filePath); - File.SetAttributes(filePath, attributes | FileAttributes.ReadOnly); - try - { - // Call - TestDelegate call = () => - { - using (new RingtoetsDatabaseFile(filePath)) {} - }; + helper.LockFiles(); - // Assert - string expectedMessage = $"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - } - finally + // Call + TestDelegate call = () => { - File.SetAttributes(filePath, attributes); - } + using (new RingtoetsDatabaseFile(filePath)) {} + }; + + // Assert + string expectedMessage = $"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); } } @@ -85,7 +77,7 @@ { // Setup string filename = Path.GetRandomFileName(); - string filePath = TestHelper.GetScratchPadPath(filename); + string filePath = TestHelper.GetScratchPadPath(nameof(ExecuteQuery_QueryIsNullOrWhiteSpace_ThrowsArgumentException) + filename); using (new FileDisposeHelper(filePath)) using (var databaseFile = new RingtoetsDatabaseFile(filePath)) @@ -105,7 +97,7 @@ { // Setup string filename = Path.GetRandomFileName(); - string filePath = TestHelper.GetScratchPadPath(filename); + string filePath = TestHelper.GetScratchPadPath(nameof(ExecuteQuery_InvalidQuery_ThrowsSQLiteException) + filename); using (new FileDisposeHelper(filePath)) using (var databaseFile = new RingtoetsDatabaseFile(filePath))