Index: Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsDatabaseFile.cs
===================================================================
diff -u -r4adc05fb0d7306ef1c21c56052193f526a4fad54 -rf53b3c70d87b9e66c3a46981b8d8a471b95e2adc
--- Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsDatabaseFile.cs (.../RingtoetsDatabaseFile.cs) (revision 4adc05fb0d7306ef1c21c56052193f526a4fad54)
+++ Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsDatabaseFile.cs (.../RingtoetsDatabaseFile.cs) (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -48,22 +48,18 @@
/// does not end with a directory or path separator (empty file name),
/// is not writable.
///
+ /// Creates the file if it does not exist.
public RingtoetsDatabaseFile(string path)
{
- IOUtils.ValidateFilePathIsWritable(path);
+ IOUtils.CreateFileIfNotExists(path);
filePath = path;
}
///
/// Opens the connection to the file.
///
- /// Creates the file if it does not exist.
public void OpenDatabaseConnection()
{
- if (!File.Exists(filePath))
- {
- SQLiteConnection.CreateFile(filePath);
- }
connection = new SQLiteConnection(SqLiteConnectionStringBuilder.BuildSqLiteConnectionString(filePath, false));
connection.Open();
}
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseFileTest.cs
===================================================================
diff -u -r94cf291c6814829fe9ea122b80e5e36a4f86486f -rf53b3c70d87b9e66c3a46981b8d8a471b95e2adc
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseFileTest.cs (.../RingtoetsDatabaseFileTest.cs) (revision 94cf291c6814829fe9ea122b80e5e36a4f86486f)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseFileTest.cs (.../RingtoetsDatabaseFileTest.cs) (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -78,24 +78,6 @@
}
[Test]
- public void OpenDatabaseConnection_FileDoesNotExist_CreatesFile()
- {
- // Setup
- string filename = Path.GetRandomFileName();
- string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
-
- using (var databaseFile = new RingtoetsDatabaseFile(filePath))
- {
- // Call
- databaseFile.OpenDatabaseConnection();
- }
-
- // Assert
- Assert.IsTrue(File.Exists(filePath));
- using (new FileDisposeHelper(filePath)) {}
- }
-
- [Test]
[TestCase("")]
[TestCase(" ")]
[TestCase(null)]
Index: Core/Common/src/Core.Common.Utils/IOUtils.cs
===================================================================
diff -u -r16bd8076863c03907abeee60b16704aba1bdb1a0 -rf53b3c70d87b9e66c3a46981b8d8a471b95e2adc
--- Core/Common/src/Core.Common.Utils/IOUtils.cs (.../IOUtils.cs) (revision 16bd8076863c03907abeee60b16704aba1bdb1a0)
+++ Core/Common/src/Core.Common.Utils/IOUtils.cs (.../IOUtils.cs) (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -209,19 +209,18 @@
}
///
- /// Validates if the file path is writable.
+ /// Creates a file at if it does not exist already.
///
- /// The file path to be validated.
+ /// The file path to be created.
/// Thrown when is invalid.
/// A valid path:
///
/// is not empty or null,
/// does not consist out of only whitespace characters,
/// does not contain an invalid character,
- /// does not end with a directory or path separator (empty file name),
- /// is writable.
+ /// does not end with a directory or path separator (empty file name).
///
- public static void ValidateFilePathIsWritable(string path)
+ public static void CreateFileIfNotExists(string path)
{
ValidateFilePath(path);
Index: Core/Common/test/Core.Common.Utils.Test/IOUtilsTest.cs
===================================================================
diff -u -r16bd8076863c03907abeee60b16704aba1bdb1a0 -rf53b3c70d87b9e66c3a46981b8d8a471b95e2adc
--- Core/Common/test/Core.Common.Utils.Test/IOUtilsTest.cs (.../IOUtilsTest.cs) (revision 16bd8076863c03907abeee60b16704aba1bdb1a0)
+++ Core/Common/test/Core.Common.Utils.Test/IOUtilsTest.cs (.../IOUtilsTest.cs) (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -341,18 +341,18 @@
[TestCase("")]
[TestCase(" ")]
[TestCase(null)]
- public void ValidateFilePathIsWritable_FilePathNullOrWhiteSpace_ThrowsArgumentException(string filePath)
+ public void CreateFileIfNotExists_FilePathNullOrWhiteSpace_ThrowsArgumentException(string filePath)
{
// Call
- TestDelegate call = () => IOUtils.ValidateFilePathIsWritable(filePath);
+ TestDelegate call = () => IOUtils.CreateFileIfNotExists(filePath);
// Assert
ArgumentException exception = Assert.Throws(call);
Assert.AreEqual($"Fout bij het lezen van bestand '{filePath}': bestandspad mag niet leeg of ongedefinieerd zijn.", exception.Message);
}
[Test]
- public void ValidateFilePathIsWritable_FileNotWritable_ThrowsArgumentException()
+ public void CreateFileIfNotExists_FileNotWritable_ThrowsArgumentException()
{
// Setup
string filename = Path.GetRandomFileName();
@@ -364,7 +364,7 @@
File.SetAttributes(filePath, attributes | FileAttributes.ReadOnly);
// Call
- TestDelegate call = () => IOUtils.ValidateFilePathIsWritable(filePath);
+ TestDelegate call = () => IOUtils.CreateFileIfNotExists(filePath);
// Assert
string expectedMessage = $"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.";
@@ -375,7 +375,7 @@
}
[Test]
- public void ValidateFilePathIsWritable_FileWritable_DoesNotThrowException()
+ public void CreateFileIfNotExists_FileWritable_DoesNotThrowException()
{
// Setup
string filename = Path.GetRandomFileName();
@@ -384,7 +384,7 @@
using (new FileDisposeHelper(filePath))
{
// Call
- TestDelegate call = () => IOUtils.ValidateFilePathIsWritable(filePath);
+ TestDelegate call = () => IOUtils.CreateFileIfNotExists(filePath);
// Assert
Assert.DoesNotThrow(call);
Index: Migration/Scripts/src/Migration.Scripts.Data/CreateScript.cs
===================================================================
diff -u -r22d820ab9e0333ce64e9ea74ac19867042906298 -rf53b3c70d87b9e66c3a46981b8d8a471b95e2adc
--- Migration/Scripts/src/Migration.Scripts.Data/CreateScript.cs (.../CreateScript.cs) (revision 22d820ab9e0333ce64e9ea74ac19867042906298)
+++ Migration/Scripts/src/Migration.Scripts.Data/CreateScript.cs (.../CreateScript.cs) (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -67,14 +67,14 @@
/// is empty or null,
/// consists out of only whitespace characters,
/// contains an invalid character,
- /// ends with a directory or path separator (empty file name),
- /// is not writable.
+ /// ends with a directory or path separator (empty file name).
///
/// Thrown when creating
/// failed.
+ /// Creates the file if it does not exist.
public IVersionedFile CreateEmptyVersionedFile(string location)
{
- IOUtils.ValidateFilePathIsWritable(location);
+ IOUtils.CreateFileIfNotExists(location);
return GetEmptyVersionedFile(location);
}
Index: Migration/Scripts/test/Migration.Scripts.Data.Test/Migration.Scripts.Data.Test.csproj
===================================================================
diff -u -raf53f335d0fa6920f7a5c4ab27b112bae9eeaede -rf53b3c70d87b9e66c3a46981b8d8a471b95e2adc
--- Migration/Scripts/test/Migration.Scripts.Data.Test/Migration.Scripts.Data.Test.csproj (.../Migration.Scripts.Data.Test.csproj) (revision af53f335d0fa6920f7a5c4ab27b112bae9eeaede)
+++ Migration/Scripts/test/Migration.Scripts.Data.Test/Migration.Scripts.Data.Test.csproj (.../Migration.Scripts.Data.Test.csproj) (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -16,16 +16,13 @@
bin\Debug\4x86
- MinimumRecommendedRules.rulesetTRACE;DEBUGfull
- nonebin\Release\4x86
- MinimumRecommendedRules.rulesetTRACEtruenone
@@ -35,7 +32,6 @@
TRACEtruex86
- MinimumRecommendedRules.rulesetnone
Index: Migration/Scripts/test/Migration.Scripts.Data.TestUtil.Test/Migration.Scripts.Data.TestUtil.Test.csproj
===================================================================
diff -u
--- Migration/Scripts/test/Migration.Scripts.Data.TestUtil.Test/Migration.Scripts.Data.TestUtil.Test.csproj (revision 0)
+++ Migration/Scripts/test/Migration.Scripts.Data.TestUtil.Test/Migration.Scripts.Data.TestUtil.Test.csproj (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -0,0 +1,60 @@
+
+
+
+ Debug
+ x86
+ {8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF}
+ Library
+ Properties
+ Migration.Scripts.Data.TestUtil.Test
+ Migration.Scripts.Data.TestUtil.Test
+ v4.0
+ 512
+
+
+ true
+ bin\Debug\
+ 4
+ x86
+ TRACE;DEBUG
+ full
+
+
+ bin\Release\
+ 4
+ x86
+ TRACE
+ true
+ none
+
+
+ bin\ReleaseForCodeCoverage\
+ TRACE
+ true
+ x86
+ none
+
+
+
+
+
+
+
+ Properties\GlobalAssembly.cs
+
+
+
+
+
+ Copying.licenseheader
+
+
+
+
+
\ No newline at end of file
Index: Migration/Scripts/test/Migration.Scripts.Data.TestUtil.Test/Properties/AssemblyInfo.cs
===================================================================
diff -u
--- Migration/Scripts/test/Migration.Scripts.Data.TestUtil.Test/Properties/AssemblyInfo.cs (revision 0)
+++ Migration/Scripts/test/Migration.Scripts.Data.TestUtil.Test/Properties/AssemblyInfo.cs (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -0,0 +1,27 @@
+// 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 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 General Public License for more details.
+//
+// You should have received a copy of the GNU 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.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Migration.Scripts.Data.TestUtil.Test")]
+[assembly: AssemblyProduct("Migration.Scripts.Data.TestUtil.Test")]
+[assembly: Guid("8adc8891-1d6c-4e15-b7bc-de9641e83bef")]
\ No newline at end of file
Index: Migration/Scripts/test/Migration.Scripts.Data.TestUtil/Migration.Scripts.Data.TestUtil.csproj
===================================================================
diff -u
--- Migration/Scripts/test/Migration.Scripts.Data.TestUtil/Migration.Scripts.Data.TestUtil.csproj (revision 0)
+++ Migration/Scripts/test/Migration.Scripts.Data.TestUtil/Migration.Scripts.Data.TestUtil.csproj (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -0,0 +1,60 @@
+
+
+
+ Debug
+ x86
+ {E4B36055-A984-4D40-9A70-34354054FE46}
+ Library
+ Properties
+ Migration.Scripts.Data.TestUtil
+ Migration.Scripts.Data.TestUtil
+ v4.0
+ 512
+
+
+ true
+ bin\Debug\
+ 4
+ x86
+ TRACE;DEBUG
+ full
+
+
+ bin\Release\
+ 4
+ x86
+ TRACE
+ true
+ none
+
+
+ bin\ReleaseForCodeCoverage\
+ TRACE
+ true
+ x86
+ none
+
+
+
+
+
+
+
+ Properties\GlobalAssembly.cs
+
+
+
+
+
+ Copying.licenseheader
+
+
+
+
+
\ No newline at end of file
Index: Migration/Scripts/test/Migration.Scripts.Data.TestUtil/Properties/AssemblyInfo.cs
===================================================================
diff -u
--- Migration/Scripts/test/Migration.Scripts.Data.TestUtil/Properties/AssemblyInfo.cs (revision 0)
+++ Migration/Scripts/test/Migration.Scripts.Data.TestUtil/Properties/AssemblyInfo.cs (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -0,0 +1,27 @@
+// 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 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 General Public License for more details.
+//
+// You should have received a copy of the GNU 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.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Migration.Scripts.Data.TestUtil")]
+[assembly: AssemblyProduct("Migration.Scripts.Data.TestUtil")]
+[assembly: Guid("e4b36055-a984-4d40-9a70-34354054fe46")]
\ No newline at end of file
Index: Ringtoets.sln
===================================================================
diff -u -r07da0e1e053d37f0867f290ebe87420805017b77 -rf53b3c70d87b9e66c3a46981b8d8a471b95e2adc
--- Ringtoets.sln (.../Ringtoets.sln) (revision 07da0e1e053d37f0867f290ebe87420805017b77)
+++ Ringtoets.sln (.../Ringtoets.sln) (revision f53b3c70d87b9e66c3a46981b8d8a471b95e2adc)
@@ -1356,6 +1356,16 @@
{C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC}
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Migration.Scripts.Data.TestUtil", "Migration\Scripts\test\Migration.Scripts.Data.TestUtil\Migration.Scripts.Data.TestUtil.csproj", "{E4B36055-A984-4D40-9A70-34354054FE46}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC}
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Migration.Scripts.Data.TestUtil.Test", "Migration\Scripts\test\Migration.Scripts.Data.TestUtil.Test\Migration.Scripts.Data.TestUtil.Test.csproj", "{8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
CreateInstaller|x86 = CreateInstaller|x86
@@ -3387,6 +3397,22 @@
{36F67E99-1546-4E12-876B-0FC121D52EEB}.Release|x86.Build.0 = Release|x86
{36F67E99-1546-4E12-876B-0FC121D52EEB}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86
{36F67E99-1546-4E12-876B-0FC121D52EEB}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86
+ {E4B36055-A984-4D40-9A70-34354054FE46}.CreateInstaller|x86.ActiveCfg = Release|x86
+ {E4B36055-A984-4D40-9A70-34354054FE46}.CreateInstallerWithDemoProject|x86.ActiveCfg = Release|x86
+ {E4B36055-A984-4D40-9A70-34354054FE46}.Debug|x86.ActiveCfg = Debug|x86
+ {E4B36055-A984-4D40-9A70-34354054FE46}.Debug|x86.Build.0 = Debug|x86
+ {E4B36055-A984-4D40-9A70-34354054FE46}.Release|x86.ActiveCfg = Release|x86
+ {E4B36055-A984-4D40-9A70-34354054FE46}.Release|x86.Build.0 = Release|x86
+ {E4B36055-A984-4D40-9A70-34354054FE46}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86
+ {E4B36055-A984-4D40-9A70-34354054FE46}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86
+ {8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF}.CreateInstaller|x86.ActiveCfg = Release|x86
+ {8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF}.CreateInstallerWithDemoProject|x86.ActiveCfg = Release|x86
+ {8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF}.Debug|x86.ActiveCfg = Debug|x86
+ {8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF}.Debug|x86.Build.0 = Debug|x86
+ {8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF}.Release|x86.ActiveCfg = Release|x86
+ {8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF}.Release|x86.Build.0 = Release|x86
+ {8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86
+ {8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -3685,6 +3711,8 @@
{1D3C098B-1EED-488C-900D-B71155C2D6AB} = {EE8D5A6C-4871-452A-A69B-F04E374D715E}
{92CFD164-3E35-440A-85A7-A7F5A43B1B12} = {1154DEBF-0456-470C-971D-9B7882D4252A}
{36F67E99-1546-4E12-876B-0FC121D52EEB} = {1154DEBF-0456-470C-971D-9B7882D4252A}
+ {E4B36055-A984-4D40-9A70-34354054FE46} = {FA7A737E-D2DB-4AD4-94CC-E3EFF242C485}
+ {8ADC8891-1D6C-4E15-B7BC-DE9641E83BEF} = {FA7A737E-D2DB-4AD4-94CC-E3EFF242C485}
EndGlobalSection
GlobalSection(TextTemplating) = postSolution
TextTemplating = 1