Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqliteCreatorTest.cs =================================================================== diff -u -r8293556a04e3650c9978df7a50f8f8ad0d792ed8 -r3456261423844a9f804b352472ac08feb22485ac --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqliteCreatorTest.cs (.../StorageSqliteCreatorTest.cs) (revision 8293556a04e3650c9978df7a50f8f8ad0d792ed8) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqliteCreatorTest.cs (.../StorageSqliteCreatorTest.cs) (revision 3456261423844a9f804b352472ac08feb22485ac) @@ -21,7 +21,6 @@ using System; using System.IO; -using Core.Common.Base.Storage; using Core.Common.TestUtil; using NUnit.Framework; @@ -56,8 +55,8 @@ // Precondition Assert.IsFalse(File.Exists(fullPath)); - - using (new FileDisposeHelper(fullPath)) + + try { // Call TestDelegate call = () => StorageSqliteCreator.CreateDatabaseStructure(fullPath); @@ -67,6 +66,13 @@ Assert.IsTrue(File.Exists(fullPath)); } + finally + { + if (File.Exists(fullPath)) + { + File.Delete(fullPath); + } + } } [Test] @@ -80,7 +86,7 @@ // Precondition Assert.IsFalse(File.Exists(fullPath)); - using (new FileDisposeHelper(fullPath)) + try { // Call TestDelegate call = () => StorageSqliteCreator.CreateDatabaseStructure(uncPath); @@ -90,26 +96,31 @@ Assert.IsTrue(File.Exists(fullPath)); } + finally + { + if (File.Exists(fullPath)) + { + File.Delete(fullPath); + } + } } [Test] - public void CreateDatabaseStructure_ValidPathToLockedFile_ThrowsUpdateStorageException() + public void CreateDatabaseStructure_ValidExistingFile_ThrowsStorageException() { using (new FileDisposeHelper(tempRingtoetsFile)) { // Call TestDelegate call = () => StorageSqliteCreator.CreateDatabaseStructure(tempRingtoetsFile); - StorageException exception; + ArgumentException exception; using (File.Create(tempRingtoetsFile)) // Locks file { - exception = Assert.Throws(call); + exception = Assert.Throws(call); } // Assert - Assert.IsInstanceOf(exception.InnerException); - var expectedMessage = String.Format(@"Fout bij het schrijven naar bestand '{0}': " + - "Een fout is opgetreden met schrijven naar het nieuwe Ringtoets bestand.", tempRingtoetsFile); + var expectedMessage = String.Format(@"File '{0}' already exists.", tempRingtoetsFile); Assert.AreEqual(expectedMessage, exception.Message); } }