Index: Migration/Scripts/test/Migration.Scripts.Data.Test/CreateScriptTest.cs =================================================================== diff -u -rd18995d638a6c3f99cb7a8419107bb4148420301 -r28ab332db2d96ad9e766f19677af1c00fc88a644 --- Migration/Scripts/test/Migration.Scripts.Data.Test/CreateScriptTest.cs (.../CreateScriptTest.cs) (revision d18995d638a6c3f99cb7a8419107bb4148420301) +++ Migration/Scripts/test/Migration.Scripts.Data.Test/CreateScriptTest.cs (.../CreateScriptTest.cs) (revision 28ab332db2d96ad9e766f19677af1c00fc88a644) @@ -62,8 +62,7 @@ // Setup const string version = "Valid version"; - string targetFilename = Path.GetRandomFileName(); - string filePath = TestHelper.GetScratchPadPath(targetFilename); + string filePath = TestHelper.GetScratchPadPath(nameof(CreateEmptyVersionedFile_FileDoesNotExist_ReturnsVersionedFile)); var createScript = new TestCreateScript(version); // Call @@ -98,22 +97,19 @@ // Setup const string version = "Valid version"; - string filename = Path.GetRandomFileName(); - string filePath = TestHelper.GetScratchPadPath(filename); + string filePath = TestHelper.GetScratchPadPath(nameof(CreateEmptyVersionedFile_FileExistsButNotWritable_ThrowsArgumentException)); var createScript = new TestCreateScript(version); - using (new FileDisposeHelper(filePath)) + using (var disposeHelper = new FileDisposeHelper(filePath)) { - FileAttributes attributes = File.GetAttributes(filePath); - File.SetAttributes(filePath, attributes | FileAttributes.ReadOnly); + disposeHelper.LockFiles(); // Call TestDelegate call = () => createScript.CreateEmptyVersionedFile(filePath); // Assert ArgumentException exception = Assert.Throws(call); Assert.AreEqual("path", exception.ParamName); - File.SetAttributes(filePath, attributes); } } }