Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs =================================================================== diff -u -r1b9445050ddc7786014349d7014c7c4d85242a5d -r736e0e16a55a0bd731f6847f85a148aa9f9f299a --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 1b9445050ddc7786014349d7014c7c4d85242a5d) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 736e0e16a55a0bd731f6847f85a148aa9f9f299a) @@ -24,7 +24,6 @@ using System.IO; using System.Linq; using System.Threading; -using System.Windows.Threading; using Application.Ringtoets.Storage.Create; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.TestUtil; @@ -66,6 +65,7 @@ public class StorageSqLiteIntegrationTest { private const string tempExtension = ".temp"; + private DirectoryDisposeHelper directoryDisposeHelper; [Test] public void SaveProjectAs_SaveAsNewFile_ProjectAsEntitiesInBothFiles() @@ -93,11 +93,6 @@ { Assert.Fail(exception.Message); } - finally - { - // TearDown - TearDownTempRingtoetsFile(secondRingtoetsFile); - } // Assert AssertProjectsAreEqual(firstProject, secondProject); @@ -225,21 +220,23 @@ mocks.VerifyAll(); } - [OneTimeTearDown] - public void TearDownTempRingtoetsFile() + [OneTimeSetUp] + public void SetUp() { - IEnumerable filesToDelete = Directory.EnumerateFiles(TestHelper.GetScratchPadPath(), $"*{tempExtension}"); + directoryDisposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(StorageSqLiteIntegrationTest)); + } - foreach (string fileToDelete in filesToDelete) - { - TearDownTempRingtoetsFile(fileToDelete); - } - Dispatcher.CurrentDispatcher.InvokeShutdown(); + [OneTimeTearDown] + public void TearDown() + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + directoryDisposeHelper.Dispose(); } private static string GetRandomRingtoetsFile() { - return Path.Combine(TestHelper.GetScratchPadPath(), + return Path.Combine(TestHelper.GetScratchPadPath(), nameof(StorageSqLiteIntegrationTest), string.Concat(Path.GetRandomFileName(), tempExtension)); } @@ -900,6 +897,20 @@ } } + #region BackgroundMapDataContainer + + private static void AssertBackgroundData(BackgroundData expectedBackgroundData, BackgroundData actualBackgroundData) + { + Assert.AreEqual(expectedBackgroundData.Name, actualBackgroundData.Name); + Assert.AreEqual(expectedBackgroundData.IsVisible, actualBackgroundData.IsVisible); + Assert.AreEqual(expectedBackgroundData.Transparency, actualBackgroundData.Transparency); + + Assert.AreEqual(expectedBackgroundData.IsConfigured, actualBackgroundData.IsConfigured); + CollectionAssert.AreEquivalent(expectedBackgroundData.Parameters, actualBackgroundData.Parameters); + } + + #endregion + #region StabilityPointStructures FailureMechanism private static void AssertStabilityPointStructuresFailureMechanism(StabilityPointStructuresFailureMechanism expectedFailureMechanism, @@ -1794,19 +1805,5 @@ } #endregion - - #region BackgroundMapDataContainer - - private static void AssertBackgroundData(BackgroundData expectedBackgroundData, BackgroundData actualBackgroundData) - { - Assert.AreEqual(expectedBackgroundData.Name, actualBackgroundData.Name); - Assert.AreEqual(expectedBackgroundData.IsVisible, actualBackgroundData.IsVisible); - Assert.AreEqual(expectedBackgroundData.Transparency, actualBackgroundData.Transparency); - - Assert.AreEqual(expectedBackgroundData.IsConfigured, actualBackgroundData.IsConfigured); - CollectionAssert.AreEquivalent(expectedBackgroundData.Parameters, actualBackgroundData.Parameters); - } - - #endregion } } \ No newline at end of file