Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageMigrationIntegrationTest.cs =================================================================== diff -u -r1a6dbc57bbe2b86d790ed9495ba20e8120aabfaa -r736e0e16a55a0bd731f6847f85a148aa9f9f299a --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageMigrationIntegrationTest.cs (.../StorageMigrationIntegrationTest.cs) (revision 1a6dbc57bbe2b86d790ed9495ba20e8120aabfaa) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageMigrationIntegrationTest.cs (.../StorageMigrationIntegrationTest.cs) (revision 736e0e16a55a0bd731f6847f85a148aa9f9f299a) @@ -39,42 +39,40 @@ [TestFixture] public class StorageMigrationIntegrationTest { + private readonly string workingDirectory = TestHelper.GetScratchPadPath(nameof(StorageMigrationIntegrationTest)); + private DirectoryDisposeHelper directoryDisposeHelper; + [Test] [TestCaseSource(typeof(RingtoetsProjectMigrationTestHelper), nameof(RingtoetsProjectMigrationTestHelper.GetAllOutdatedSupportedProjectFilePaths))] [Apartment(ApartmentState.STA)] public void GivenRingtoetsGuiWithStorageSql_WhenRunWithMigratedFile_MigratedProjectSet(string sourceFilePath) { - string targetFilePath = TestHelper.GetScratchPadPath(nameof(GivenRingtoetsGuiWithStorageSql_WhenRunWithMigratedFile_MigratedProjectSet)); - using (new FileDisposeHelper(targetFilePath)) - { - MigrateFile(sourceFilePath, targetFilePath); + string targetFilePath = Path.Combine(workingDirectory, nameof(GivenRingtoetsGuiWithStorageSql_WhenRunWithMigratedFile_MigratedProjectSet)); + MigrateFile(sourceFilePath, targetFilePath); - // Given - var projectStore = new StorageSqLite(); + // Given + var projectStore = new StorageSqLite(); + var mocks = new MockRepository(); + var inquiryHelper = mocks.StrictMock(); + mocks.ReplayAll(); - var mocks = new MockRepository(); - var inquiryHelper = mocks.StrictMock(); - mocks.ReplayAll(); + var projectMigrator = new RingtoetsProjectMigrator(inquiryHelper); - var projectMigrator = new RingtoetsProjectMigrator(inquiryHelper); + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RingtoetsProjectFactory(), new GuiCoreSettings())) + { + // When + gui.Run(targetFilePath); - using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RingtoetsProjectFactory(), new GuiCoreSettings())) - { - // When - gui.Run(targetFilePath); - - // Then - Assert.AreEqual(targetFilePath, gui.ProjectFilePath); - Assert.NotNull(gui.Project); - string expectedProjectName = Path.GetFileNameWithoutExtension(targetFilePath); - Assert.AreEqual(expectedProjectName, gui.Project.Name); - Assert.AreEqual("description", gui.Project.Description); - Assert.IsInstanceOf(gui.Project); - } - GC.WaitForPendingFinalizers(); - - mocks.VerifyAll(); + // Then + Assert.AreEqual(targetFilePath, gui.ProjectFilePath); + Assert.NotNull(gui.Project); + string expectedProjectName = Path.GetFileNameWithoutExtension(targetFilePath); + Assert.AreEqual(expectedProjectName, gui.Project.Name); + Assert.AreEqual("description", gui.Project.Description); + Assert.IsInstanceOf(gui.Project); } + + mocks.VerifyAll(); } [Test] @@ -83,39 +81,35 @@ public void GivenRingtoetsGui_WhenRunWithUnmigratedFileAndInquireContinuation_MigratedProjectSet(string sourceFilePath) { // Given - string targetFilePath = TestHelper.GetScratchPadPath(nameof(GivenRingtoetsGui_WhenRunWithUnmigratedFileAndInquireContinuation_MigratedProjectSet)); - using (new FileDisposeHelper(targetFilePath)) - { - var projectStore = new StorageSqLite(); + string targetFilePath = Path.Combine(workingDirectory, nameof(GivenRingtoetsGui_WhenRunWithUnmigratedFileAndInquireContinuation_MigratedProjectSet)); - var mocks = new MockRepository(); - var inquiryHelper = mocks.Stub(); - inquiryHelper.Expect(helper => helper.InquireContinuation(null)) - .IgnoreArguments() - .Return(true); - inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null)) - .IgnoreArguments() - .Return(targetFilePath); - mocks.ReplayAll(); + var projectStore = new StorageSqLite(); + var mocks = new MockRepository(); + var inquiryHelper = mocks.Stub(); + inquiryHelper.Expect(helper => helper.InquireContinuation(null)) + .IgnoreArguments() + .Return(true); + inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null)) + .IgnoreArguments() + .Return(targetFilePath); + mocks.ReplayAll(); - var projectMigrator = new RingtoetsProjectMigrator(inquiryHelper); + var projectMigrator = new RingtoetsProjectMigrator(inquiryHelper); - using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RingtoetsProjectFactory(), new GuiCoreSettings())) - { - // When - gui.Run(sourceFilePath); + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RingtoetsProjectFactory(), new GuiCoreSettings())) + { + // When + gui.Run(sourceFilePath); - // Then - Assert.AreEqual(targetFilePath, gui.ProjectFilePath); - string expectedProjectName = Path.GetFileNameWithoutExtension(targetFilePath); - Assert.AreEqual(expectedProjectName, gui.Project.Name); - Assert.AreEqual("description", gui.Project.Description); - Assert.IsInstanceOf(gui.Project); - } - GC.WaitForPendingFinalizers(); - - mocks.VerifyAll(); + // Then + Assert.AreEqual(targetFilePath, gui.ProjectFilePath); + string expectedProjectName = Path.GetFileNameWithoutExtension(targetFilePath); + Assert.AreEqual(expectedProjectName, gui.Project.Name); + Assert.AreEqual("description", gui.Project.Description); + Assert.IsInstanceOf(gui.Project); } + + mocks.VerifyAll(); } [Test] @@ -125,7 +119,6 @@ { // Given var projectStore = new StorageSqLite(); - var mocks = new MockRepository(); var inquiryHelper = mocks.Stub(); inquiryHelper.Expect(helper => helper.InquireContinuation(null)) @@ -145,11 +138,24 @@ Assert.AreEqual("Project", gui.Project.Name); Assert.IsEmpty(gui.Project.Description); } - GC.WaitForPendingFinalizers(); mocks.VerifyAll(); } + [OneTimeSetUp] + public void SetUp() + { + directoryDisposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(StorageMigrationIntegrationTest)); + } + + [OneTimeTearDown] + public void TearDown() + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + directoryDisposeHelper.Dispose(); + } + private static void MigrateFile(string sourceFilePath, string targetFilePath) { string newVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();