Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r8e5f037ed7df5263d26ba1ada373be196e7a354b -r2af16641280bfec489b54f50f4d32cb29260e0b8
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 8e5f037ed7df5263d26ba1ada373be196e7a354b)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 2af16641280bfec489b54f50f4d32cb29260e0b8)
@@ -449,7 +449,6 @@
-
@@ -467,6 +466,11 @@
Ringtoets.ClosingStructures.Data
False
+
+ {6A074D65-A81C-4C1C-8E24-F36C916E4ED7}
+ Ringtoets.Common.Utils
+ False
+
{d1068432-c172-4aa6-847b-d9deb4c6de26}
Ringtoets.DuneErosion.Data
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs
===================================================================
diff -u -r16bd8076863c03907abeee60b16704aba1bdb1a0 -r2af16641280bfec489b54f50f4d32cb29260e0b8
--- Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision 16bd8076863c03907abeee60b16704aba1bdb1a0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision 2af16641280bfec489b54f50f4d32cb29260e0b8)
@@ -35,6 +35,7 @@
using Core.Common.Utils;
using Core.Common.Utils.Builders;
using log4net;
+using Ringtoets.Common.Utils;
using Ringtoets.Integration.Data;
using UtilsResources = Core.Common.Utils.Properties.Resources;
@@ -183,7 +184,7 @@
{
dbContext.VersionEntities.Add(new VersionEntity
{
- Version = VersionHelper.GetCurrentDatabaseVersion(),
+ Version = RingtoetsVersionHelper.GetCurrentDatabaseVersion(),
Timestamp = DateTime.Now,
FingerPrint = FingerprintHelper.Get(stagedProject.Entity)
});
@@ -215,18 +216,18 @@
try
{
string databaseVersion = ringtoetsEntities.VersionEntities.Select(v => v.Version).Single();
- if (!VersionHelper.IsValidVersion(databaseVersion))
+ if (!RingtoetsVersionHelper.IsValidVersion(databaseVersion))
{
string m = string.Format(Resources.StorageSqLite_ValidateDatabaseVersion_DatabaseVersion_0_is_invalid,
databaseVersion);
var message = new FileReaderErrorMessageBuilder(databaseFilePath).Build(m);
throw new StorageValidationException(message);
}
- if (VersionHelper.IsNewerThanCurrent(databaseVersion))
+ if (RingtoetsVersionHelper.IsNewerThanCurrent(databaseVersion))
{
string m = string.Format(Resources.StorageSqLite_ValidateDatabaseVersion_DatabaseVersion_0_higher_then_current_DatabaseVersion_1_,
- databaseVersion, VersionHelper.GetCurrentDatabaseVersion());
+ databaseVersion, RingtoetsVersionHelper.GetCurrentDatabaseVersion());
var message = new FileReaderErrorMessageBuilder(databaseFilePath).Build(m);
throw new StorageValidationException(message);
}
Fisheye: Tag 2af16641280bfec489b54f50f4d32cb29260e0b8 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/VersionHelper.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r8e5f037ed7df5263d26ba1ada373be196e7a354b -r2af16641280bfec489b54f50f4d32cb29260e0b8
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 8e5f037ed7df5263d26ba1ada373be196e7a354b)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 2af16641280bfec489b54f50f4d32cb29260e0b8)
@@ -236,7 +236,6 @@
-
@@ -263,6 +262,10 @@
{f5b43c29-6169-4e9a-859e-09090330b94e}
Ringtoets.ClosingStructures.Data.TestUtil
+
+ {6A074D65-A81C-4C1C-8E24-F36C916E4ED7}
+ Ringtoets.Common.Utils
+
{D1068432-C172-4AA6-847B-D9DEB4C6DE26}
Ringtoets.DuneErosion.Data
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqLiteTest.cs
===================================================================
diff -u -r8e5f037ed7df5263d26ba1ada373be196e7a354b -r2af16641280bfec489b54f50f4d32cb29260e0b8
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqLiteTest.cs (.../StorageSqLiteTest.cs) (revision 8e5f037ed7df5263d26ba1ada373be196e7a354b)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqLiteTest.cs (.../StorageSqLiteTest.cs) (revision 2af16641280bfec489b54f50f4d32cb29260e0b8)
@@ -29,6 +29,7 @@
using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
+using Ringtoets.Common.Utils;
using Ringtoets.Integration.Data;
namespace Application.Ringtoets.Storage.Test
@@ -196,7 +197,7 @@
{
// Setup
string expectedMessage = $@"Fout bij het lezen van bestand '{tempRingtoetsFile}': {"database moet één rij in de VersionEntity tabel hebben."}";
- string currentDatabaseVersion = VersionHelper.GetCurrentDatabaseVersion();
+ string currentDatabaseVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(tempRingtoetsFile);
try
{
@@ -230,7 +231,7 @@
public void LoadProject_DatabaseFromFutureVersion_ThrowStorageValidationException(int additionalVersionNumber)
{
// Setup
- string currentDatabaseVersion = VersionHelper.GetCurrentDatabaseVersion();
+ string currentDatabaseVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
var versionCode = additionalVersionNumber + currentDatabaseVersion;
string subMessage = $"ringtoets bestand versie '{versionCode}' is hoger dan de huidig ondersteunde versie ('{currentDatabaseVersion}'). Update Ringtoets naar een nieuwere versie.";
string expectedMessage = $@"Fout bij het lezen van bestand '{tempRingtoetsFile}': {subMessage}";
Fisheye: Tag 2af16641280bfec489b54f50f4d32cb29260e0b8 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/VersionHelperTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Migration/Core/src/Migration.Core.Storage/Migration.Core.Storage.csproj
===================================================================
diff -u -r1a90e7c188f16e5e075c39bee9c715bfddbc00f3 -r2af16641280bfec489b54f50f4d32cb29260e0b8
--- Migration/Core/src/Migration.Core.Storage/Migration.Core.Storage.csproj (.../Migration.Core.Storage.csproj) (revision 1a90e7c188f16e5e075c39bee9c715bfddbc00f3)
+++ Migration/Core/src/Migration.Core.Storage/Migration.Core.Storage.csproj (.../Migration.Core.Storage.csproj) (revision 2af16641280bfec489b54f50f4d32cb29260e0b8)
@@ -83,6 +83,10 @@
{F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
Core.Common.Utils
+
+ {6A074D65-A81C-4C1C-8E24-F36C916E4ED7}
+ Ringtoets.Common.Utils
+
{EED7826A-5397-4EEB-A1F8-A7550078459E}
Migration.Ringtoets.Data
Index: Ringtoets/Common/src/Ringtoets.Common.Utils/Ringtoets.Common.Utils.csproj
===================================================================
diff -u -r23d1e296e2da4364fbfe346e68d582dfcf966bb0 -r2af16641280bfec489b54f50f4d32cb29260e0b8
--- Ringtoets/Common/src/Ringtoets.Common.Utils/Ringtoets.Common.Utils.csproj (.../Ringtoets.Common.Utils.csproj) (revision 23d1e296e2da4364fbfe346e68d582dfcf966bb0)
+++ Ringtoets/Common/src/Ringtoets.Common.Utils/Ringtoets.Common.Utils.csproj (.../Ringtoets.Common.Utils.csproj) (revision 2af16641280bfec489b54f50f4d32cb29260e0b8)
@@ -46,6 +46,7 @@
+
Index: Ringtoets/Common/src/Ringtoets.Common.Utils/RingtoetsVersionHelper.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Utils/RingtoetsVersionHelper.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Utils/RingtoetsVersionHelper.cs (revision 2af16641280bfec489b54f50f4d32cb29260e0b8)
@@ -0,0 +1,103 @@
+// 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;
+using System.Linq;
+
+namespace Ringtoets.Common.Utils
+{
+ ///
+ /// This class is capable of comparing Ringtoets database versions.
+ ///
+ public static class RingtoetsVersionHelper
+ {
+ private const string validDatabaseversion = "4";
+ private const string currentDatabaseVersion = "17.1";
+ private const string versionSeparator = ".";
+
+ ///
+ /// Gets the current database version.
+ ///
+ /// The database version.
+ public static string GetCurrentDatabaseVersion()
+ {
+ return currentDatabaseVersion;
+ }
+
+ ///
+ /// Returns if the is newer than the current database version.
+ ///
+ /// The version to compare.
+ /// true is is newer than the current
+ /// database version, false otherwise.
+ public static bool IsNewerThanCurrent(string version)
+ {
+ return CompareToVersion(version, currentDatabaseVersion) > 0;
+ }
+
+ ///
+ /// Returns if the is a valid database version.
+ ///
+ /// The version to compare.
+ /// true is is a valid database version,
+ /// false otherwise.
+ public static bool IsValidVersion(string version)
+ {
+ return CompareToVersion(version, validDatabaseversion) >= 0;
+ }
+
+ public static int CompareToVersion(string versionString, string compareString)
+ {
+ var separatorArray = versionSeparator.ToCharArray();
+ string[] versionArray = versionString.Split(separatorArray, StringSplitOptions.RemoveEmptyEntries);
+ string[] currentVersionArray = compareString.Split(separatorArray, StringSplitOptions.RemoveEmptyEntries);
+
+ if (versionArray.Length < 1)
+ {
+ return -1;
+ }
+
+ if (currentVersionArray.Length < 1)
+ {
+ return 1;
+ }
+
+ int version;
+ int.TryParse(versionArray[0], out version);
+
+ int currentVersion;
+ int.TryParse(currentVersionArray[0], out currentVersion);
+
+ var compareTo = version.CompareTo(currentVersion);
+ if (compareTo > 0)
+ {
+ return compareTo;
+ }
+ if (compareTo == 0 && versionArray.Length > 1)
+ {
+ var newVersionString = string.Join(versionSeparator, versionArray.Skip(1).ToArray());
+ var newCurrentVersionString = string.Join(versionSeparator, currentVersionArray.Skip(1).ToArray());
+ return CompareToVersion(newVersionString, newCurrentVersionString);
+ }
+ return compareTo;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Utils.Test/Ringtoets.Common.Utils.Test.csproj
===================================================================
diff -u -r6a5d7b40b7ba4dcb73e393075338352d194e97c2 -r2af16641280bfec489b54f50f4d32cb29260e0b8
--- Ringtoets/Common/test/Ringtoets.Common.Utils.Test/Ringtoets.Common.Utils.Test.csproj (.../Ringtoets.Common.Utils.Test.csproj) (revision 6a5d7b40b7ba4dcb73e393075338352d194e97c2)
+++ Ringtoets/Common/test/Ringtoets.Common.Utils.Test/Ringtoets.Common.Utils.Test.csproj (.../Ringtoets.Common.Utils.Test.csproj) (revision 2af16641280bfec489b54f50f4d32cb29260e0b8)
@@ -61,6 +61,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Utils.Test/RingtoetsVersionHelperTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Utils.Test/RingtoetsVersionHelperTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Utils.Test/RingtoetsVersionHelperTest.cs (revision 2af16641280bfec489b54f50f4d32cb29260e0b8)
@@ -0,0 +1,110 @@
+// 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 NUnit.Framework;
+
+namespace Ringtoets.Common.Utils.Test
+{
+ [TestFixture]
+ public class RingtoetsVersionHelperTest
+ {
+ [Test]
+ public void GetCurrentDatabaseversion_ReturnsExpectedValue()
+ {
+ // Call
+ string currentVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
+
+ // Assert
+ Assert.AreEqual("17.1", currentVersion);
+ }
+
+ [Test]
+ [TestCase("9000.0")]
+ [TestCase("17.2")]
+ public void IsNewerThanCurrentString_NewerVersion_ReturnsTrue(string newerVersion)
+ {
+ // Call
+ bool isNewer = RingtoetsVersionHelper.IsNewerThanCurrent(newerVersion);
+
+ // Assert
+ Assert.IsTrue(isNewer);
+ }
+
+ [Test]
+ public void IsNewerThanCurrentString_SameVersion_ReturnsFalse()
+ {
+ // Setup
+ string currentVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
+
+ // Call
+ bool isNewer = RingtoetsVersionHelper.IsNewerThanCurrent(currentVersion);
+
+ // Assert
+ Assert.IsFalse(isNewer);
+ }
+
+ [Test]
+ [TestCase("4")]
+ [TestCase("17.0")]
+ public void IsNewerThanCurrentString_OlderVersion_ReturnsFalse(string olderVersion)
+ {
+ // Call
+ bool isNewer = RingtoetsVersionHelper.IsNewerThanCurrent(olderVersion);
+
+ // Assert
+ Assert.IsFalse(isNewer);
+ }
+
+ [Test]
+ [TestCase("4a.0")]
+ [TestCase("17..")]
+ public void IsNewerThanCurrentString_InvalidVersion_ReturnsFalse(string invalidVersion)
+ {
+ // Call
+ bool isNewer = RingtoetsVersionHelper.IsNewerThanCurrent(invalidVersion);
+
+ // Assert
+ Assert.IsFalse(isNewer);
+ }
+
+ [Test]
+ [TestCase("4")]
+ [TestCase("17")]
+ public void IsValidVersion_ValidVersion_ReturnsTrue(string validVersion)
+ {
+ bool isNewer = RingtoetsVersionHelper.IsValidVersion(validVersion);
+
+ // Assert
+ Assert.IsTrue(isNewer);
+ }
+
+ [Test]
+ [TestCase("3")]
+ [TestCase("..")]
+ public void IsValidVersion_InvalidVersion_ReturnsFalse(string invalidVersion)
+ {
+ bool isNewer = RingtoetsVersionHelper.IsValidVersion(invalidVersion);
+
+ // Assert
+ Assert.IsFalse(isNewer);
+ }
+ }
+}
\ No newline at end of file