Index: Application/Ringtoets/src/Application.Ringtoets.Migration/Application.Ringtoets.Migration.csproj =================================================================== diff -u -r3c04633ccf2eacbc1e0dc2db5a2a381080c3a035 -r5ec759496df2662a183c1c5ed74e3724bd834ae2 --- Application/Ringtoets/src/Application.Ringtoets.Migration/Application.Ringtoets.Migration.csproj (.../Application.Ringtoets.Migration.csproj) (revision 3c04633ccf2eacbc1e0dc2db5a2a381080c3a035) +++ Application/Ringtoets/src/Application.Ringtoets.Migration/Application.Ringtoets.Migration.csproj (.../Application.Ringtoets.Migration.csproj) (revision 5ec759496df2662a183c1c5ed74e3724bd834ae2) @@ -64,6 +64,11 @@ + + {3bbfd65b-b277-4e50-ae6d-bd24c3434609} + Core.Common.Base + False + {30e4c2ae-719e-4d70-9fa9-668a9767fbfa} Core.Common.Gui Index: Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs =================================================================== diff -u -rb6d487f36edb7b6ca133a0e26d1ab7bda4c6bab6 -r5ec759496df2662a183c1c5ed74e3724bd834ae2 --- Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs (.../RingtoetsProjectMigrator.cs) (revision b6d487f36edb7b6ca133a0e26d1ab7bda4c6bab6) +++ Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs (.../RingtoetsProjectMigrator.cs) (revision 5ec759496df2662a183c1c5ed74e3724bd834ae2) @@ -24,6 +24,7 @@ using System.Windows.Forms; using Application.Ringtoets.Migration.Core; using Application.Ringtoets.Migration.Properties; +using Core.Common.Base.Storage; using Core.Common.Gui; using Core.Common.Utils; using log4net; @@ -37,7 +38,7 @@ /// /// A GUI implementation to migrate a Ringtoets database file to a newer version. /// - public class RingtoetsProjectMigrator + public class RingtoetsProjectMigrator : IMigrateProject { private static readonly string currentProjectVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion(); @@ -63,18 +64,6 @@ Resources.RingtoetsProject_FileExtension); } - /// - /// Indicates if the project needs to be - /// updated to the newest version. - /// - /// The file path of the project which needs to be checked. - /// true if the file needs to be migrated, false if: - /// - /// The file does not need to be migrated. - /// The file is not supported for the migration. - /// - /// Thrown when is null. - /// Thrown when is an invalid file path. public bool ShouldMigrate(string sourceFilePath) { if (sourceFilePath == null) @@ -102,18 +91,6 @@ return isVersionSupported; } - /// - /// Migrates an outdated project file from - /// to the newest project version version at a user defined target filepath. - /// - /// The project file which needs to be migrated. - /// A filepath to the updated project file. null if: - /// - /// The user cancelled. - /// The migration failed. - /// - /// Thrown when is null. - /// Thrown when is an invalid file path. public string Migrate(string sourceFilePath) { if (sourceFilePath == null) Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/Application.Ringtoets.Migration.Test.csproj =================================================================== diff -u -rb6d487f36edb7b6ca133a0e26d1ab7bda4c6bab6 -r5ec759496df2662a183c1c5ed74e3724bd834ae2 --- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/Application.Ringtoets.Migration.Test.csproj (.../Application.Ringtoets.Migration.Test.csproj) (revision b6d487f36edb7b6ca133a0e26d1ab7bda4c6bab6) +++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/Application.Ringtoets.Migration.Test.csproj (.../Application.Ringtoets.Migration.Test.csproj) (revision 5ec759496df2662a183c1c5ed74e3724bd834ae2) @@ -64,6 +64,10 @@ + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + {30E4C2AE-719E-4D70-9FA9-668A9767FBFA} Core.Common.Gui Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs =================================================================== diff -u -rb6d487f36edb7b6ca133a0e26d1ab7bda4c6bab6 -r5ec759496df2662a183c1c5ed74e3724bd834ae2 --- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs (.../RingtoetsProjectMigratorTest.cs) (revision b6d487f36edb7b6ca133a0e26d1ab7bda4c6bab6) +++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs (.../RingtoetsProjectMigratorTest.cs) (revision 5ec759496df2662a183c1c5ed74e3724bd834ae2) @@ -24,6 +24,7 @@ using System.Linq; using System.Threading; using Application.Ringtoets.Migration.Core; +using Core.Common.Base.Storage; using Core.Common.Gui; using Core.Common.TestUtil; using NUnit.Extensions.Forms; @@ -61,8 +62,7 @@ var migrator = new RingtoetsProjectMigrator(inquiryHelper); // Assert - // TODO: introduce the IMigrateProject in Core.Common.Base - Assert.IsInstanceOf(migrator); + Assert.IsInstanceOf(migrator); mocks.VerifyAll(); } @@ -238,7 +238,7 @@ string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Application.Ringtoets.Migration, "FullTestProject164.rtd"); string targetFile = $"{nameof(GivenMigratorAndSupportedFile_WhenContinuedAfterInquiryAndValidTargetLocationGivenWithoutExtension_ThenFileSuccessFullyMigratesAndExtensionAdded)}"; - string targetFilePath = TestHelper.GetScratchPadPath(Path.Combine(testDirectory, targetFile)); + string targetFilePath = Path.Combine(TestHelper.GetScratchPadPath(), testDirectory, targetFile); string expectedVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion(); var mocks = new MockRepository(); @@ -286,7 +286,7 @@ string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Application.Ringtoets.Migration, "FullTestProject164.rtd"); string targetFile = $"{nameof(GivenMigratorAndSupportedFile_WhenContinuedAfterInquiryAndValidTargetLocationGiven_ThenFileSuccessFullyMigrates)}.rtd"; - string targetFilePath = TestHelper.GetScratchPadPath(Path.Combine(testDirectory, targetFile)); + string targetFilePath = Path.Combine(TestHelper.GetScratchPadPath(), testDirectory, targetFile); string expectedVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion(); var mocks = new MockRepository(); @@ -398,7 +398,7 @@ // Setup string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Application.Ringtoets.Migration, "UnsupportedVersion8.rtd"); string targetFile = $"{nameof(Migrate_UnsupportedSourceFileVersion_ThenLogsError)}"; - string targetFilePath = TestHelper.GetScratchPadPath(Path.Combine(testDirectory, targetFile)); + string targetFilePath = Path.Combine(TestHelper.GetScratchPadPath(), testDirectory, targetFile); var mocks = new MockRepository(); var inquiryHelper = mocks.StrictMock(); Index: Core/Common/src/Core.Common.Base/Core.Common.Base.csproj =================================================================== diff -u -r66b07e7599319ea71ff109d8303f74a4a2e5f71c -r5ec759496df2662a183c1c5ed74e3724bd834ae2 --- Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 66b07e7599319ea71ff109d8303f74a4a2e5f71c) +++ Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 5ec759496df2662a183c1c5ed74e3724bd834ae2) @@ -106,6 +106,7 @@ + Index: Core/Common/src/Core.Common.Base/Storage/IMigrateProject.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Base/Storage/IMigrateProject.cs (revision 0) +++ Core/Common/src/Core.Common.Base/Storage/IMigrateProject.cs (revision 5ec759496df2662a183c1c5ed74e3724bd834ae2) @@ -0,0 +1,59 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; + +namespace Core.Common.Base.Storage +{ + /// + /// Interface that describes the methods that need to be implemented on classes that provide a storage for projects. + /// + public interface IMigrateProject + { + /// + /// Indicates if the project from needs to be + /// updated to the newest version. + /// + /// The file path of the project which needs to be checked. + /// true if the file needs to be migrated, false if: + /// + /// The file does not need to be migrated. + /// The file is not supported for the migration. + /// + /// Thrown when is null. + /// Thrown when is an invalid file path. + bool ShouldMigrate(string sourceFilePath); + + /// + /// Migrates an outdated project file from + /// to the newest project version version at a user defined target filepath. + /// + /// The project file which needs to be migrated. + /// A filepath to the updated project file. null if: + /// + /// The user cancelled. + /// The migration failed. + /// + /// Thrown when is null. + /// Thrown when is an invalid file path. + string Migrate(string sourceFilePath); + } +}