Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationDatabaseQueryBuilder.cs
===================================================================
diff -u -r733d0d51adf737c52704cd80705507fdb34a2ba3 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationDatabaseQueryBuilder.cs (.../HydraulicLocationConfigurationDatabaseQueryBuilder.cs) (revision 733d0d51adf737c52704cd80705507fdb34a2ba3)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationDatabaseQueryBuilder.cs (.../HydraulicLocationConfigurationDatabaseQueryBuilder.cs) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -29,25 +29,16 @@
public static class HydraulicLocationConfigurationDatabaseQueryBuilder
{
///
- /// Returns the query to get the LocationId from the database.
+ /// Returns the query to get the LocationIds from the database.
///
- /// The query to get the locationId from the database.
- public static string GetLocationIdQuery()
+ /// The query to get the locationIds from the database.
+ public static string GetLocationsIdByRegionIdQuery()
{
- var countQuery = String.Format("Select COUNT({0}) FROM {1} WHERE {2} = @{2} AND {3} = @{3}",
- LocationsTableDefinitions.LocationId,
- LocationsTableDefinitions.TableName,
- LocationsTableDefinitions.RegionId,
- LocationsTableDefinitions.HrdLocationId);
-
- return String.Format("SELECT {0}, ({1}) as {2} FROM {3} WHERE {4} = @{4} AND {5} = @{5};",
+ return String.Format("SELECT {0}, {1} FROM {2} WHERE {3} = @{3} ORDER BY {1};",
LocationsTableDefinitions.LocationId,
- countQuery,
- LocationsTableDefinitions.Count,
+ LocationsTableDefinitions.HrdLocationId,
LocationsTableDefinitions.TableName,
- LocationsTableDefinitions.RegionId,
- LocationsTableDefinitions.HrdLocationId
- );
+ LocationsTableDefinitions.RegionId);
}
}
}
\ No newline at end of file
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationSqLiteDatabaseReader.cs
===================================================================
diff -u -rfc22f4b149d07797f0526f04ca58595bb9446786 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationSqLiteDatabaseReader.cs (.../HydraulicLocationConfigurationSqLiteDatabaseReader.cs) (revision fc22f4b149d07797f0526f04ca58595bb9446786)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationSqLiteDatabaseReader.cs (.../HydraulicLocationConfigurationSqLiteDatabaseReader.cs) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using Core.Common.IO.Exceptions;
@@ -51,33 +52,25 @@
public HydraulicLocationConfigurationSqLiteDatabaseReader(string databaseFilePath) : base(databaseFilePath) {}
///
- /// Gets the location id from the database, based upon and .
+ /// Gets the location ids from the database, based upon .
///
/// Hydraulic boundary region id.
- /// Hydraulic boundary location id.
- /// The location id found in the database, or 0 otherwise.
+ /// List of location id and Hrd location id found in the database.
/// Thrown when the database query failed.
/// Thrown when the database returned incorrect values for
/// required properties.
- public int GetLocationId(long regionId, long hrdLocationId)
+ public Dictionary GetLocationsIdByRegionId(long regionId)
{
- var locationIdQuery = HydraulicLocationConfigurationDatabaseQueryBuilder.GetLocationIdQuery();
var regionParameter = new SQLiteParameter
{
DbType = DbType.String,
ParameterName = LocationsTableDefinitions.RegionId,
Value = regionId
};
- var hrdLocationParameter = new SQLiteParameter
- {
- DbType = DbType.String,
- ParameterName = LocationsTableDefinitions.HrdLocationId,
- Value = hrdLocationId
- };
try
{
- return GetLocationIdFromDatabase(locationIdQuery, regionParameter, hrdLocationParameter);
+ return GetLocationIdsFromDatabase(regionParameter);
}
catch (InvalidCastException exception)
{
@@ -91,23 +84,29 @@
}
}
- private int GetLocationIdFromDatabase(string locationIdQuery, SQLiteParameter regionParameter, SQLiteParameter hrdLocationParameter)
+ private Dictionary GetLocationIdsFromDatabase(SQLiteParameter regionParameter)
{
- using (SQLiteDataReader dataReader = CreateDataReader(locationIdQuery, regionParameter, hrdLocationParameter))
+ var dictionary = new Dictionary();
+ var locationIdQuery = HydraulicLocationConfigurationDatabaseQueryBuilder.GetLocationsIdByRegionIdQuery();
+ using (SQLiteDataReader dataReader = CreateDataReader(locationIdQuery, regionParameter))
{
- if (!dataReader.Read())
+ while (MoveNext(dataReader))
{
- return 0;
- }
- var locationCount = Convert.ToInt32(dataReader[LocationsTableDefinitions.Count]);
+ var key = Convert.ToInt64(dataReader[LocationsTableDefinitions.HrdLocationId]);
+ var value = Convert.ToInt64(dataReader[LocationsTableDefinitions.LocationId]);
- // Must be unique
- if (locationCount > 1)
- {
- log.Warn(Resources.HydraulicLocationConfigurationSqLiteDatabaseReader_GetLocationIdFromDatabase_Ambiguous_Row_Found_Take_First);
+ // Must be unique
+ if (dictionary.ContainsKey(key))
+ {
+ log.Warn(Resources.HydraulicLocationConfigurationSqLiteDatabaseReader_GetLocationIdFromDatabase_Ambiguous_Row_Found_Take_First);
+ }
+ else
+ {
+ dictionary.Add(key, value);
+ }
}
- return Convert.ToInt32(dataReader[LocationsTableDefinitions.LocationId]);
}
+ return dictionary;
}
}
}
\ No newline at end of file
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicLocationConfigurationDatabaseContext/LocationsTableDefinitions.cs
===================================================================
diff -u -r733d0d51adf737c52704cd80705507fdb34a2ba3 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicLocationConfigurationDatabaseContext/LocationsTableDefinitions.cs (.../LocationsTableDefinitions.cs) (revision 733d0d51adf737c52704cd80705507fdb34a2ba3)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicLocationConfigurationDatabaseContext/LocationsTableDefinitions.cs (.../LocationsTableDefinitions.cs) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -31,6 +31,5 @@
internal const string LocationId = "LocationId";
internal const string HrdLocationId = "HRDLocationId";
internal const string RegionId = "RegionId";
- internal const string Count = "nrOfRows";
}
}
\ No newline at end of file
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationDatabaseQueryBuilderTest.cs
===================================================================
diff -u -r733d0d51adf737c52704cd80705507fdb34a2ba3 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationDatabaseQueryBuilderTest.cs (.../HydraulicLocationConfigurationDatabaseQueryBuilderTest.cs) (revision 733d0d51adf737c52704cd80705507fdb34a2ba3)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationDatabaseQueryBuilderTest.cs (.../HydraulicLocationConfigurationDatabaseQueryBuilderTest.cs) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -28,15 +28,13 @@
public class HydraulicLocationConfigurationDatabaseQueryBuilderTest
{
[Test]
- public void GetLocationIdQuery_Always_ReturnsExpectedValues()
+ public void GetLocationsIdByRegionIdQuery_Always_ReturnsExpectedValues()
{
// Setup
- string expectedQuery = "SELECT LocationId, " +
- "(Select COUNT(LocationId) FROM Locations WHERE RegionId = @RegionId AND HRDLocationId = @HRDLocationId) as nrOfRows " +
- "FROM Locations WHERE RegionId = @RegionId AND HRDLocationId = @HRDLocationId;";
+ string expectedQuery = "SELECT LocationId, HRDLocationId FROM Locations WHERE RegionId = @RegionId ORDER BY HRDLocationId;";
// Call
- string query = HydraulicLocationConfigurationDatabaseQueryBuilder.GetLocationIdQuery();
+ string query = HydraulicLocationConfigurationDatabaseQueryBuilder.GetLocationsIdByRegionIdQuery();
// Assert
Assert.AreEqual(expectedQuery, query);
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationSqLiteDatabaseReaderTest.cs
===================================================================
diff -u -r733d0d51adf737c52704cd80705507fdb34a2ba3 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationSqLiteDatabaseReaderTest.cs (.../HydraulicLocationConfigurationSqLiteDatabaseReaderTest.cs) (revision 733d0d51adf737c52704cd80705507fdb34a2ba3)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/HydraulicLocationConfigurationDatabaseContext/HydraulicLocationConfigurationSqLiteDatabaseReaderTest.cs (.../HydraulicLocationConfigurationSqLiteDatabaseReaderTest.cs) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.Data.SQLite;
using System.IO;
using Core.Common.IO.Exceptions;
@@ -72,61 +73,64 @@
[TestCase(1, 1, 100001)]
[TestCase(18, 1000, 1801000)]
[TestCase(6, 1000, 0)]
- public void GetLocationId_ValidFile_ExpectedValues(int regionId, int hrdLocationId, int expectedLocationId)
+ public void GetLocationsIdByRegionId_ValidFile_ExpectedValues(int regionId, int hrdLocationId, int expectedLocationId)
{
// Setup
var dbFile = Path.Combine(testDataPath, "complete.sqlite");
using (HydraulicLocationConfigurationSqLiteDatabaseReader hydraulicBoundarySqLiteDatabaseReader = new HydraulicLocationConfigurationSqLiteDatabaseReader(dbFile))
{
// Call
- int locationId = hydraulicBoundarySqLiteDatabaseReader.GetLocationId(regionId, hrdLocationId);
+ Dictionary locationIdDictionary = hydraulicBoundarySqLiteDatabaseReader.GetLocationsIdByRegionId(regionId);
// Assert
+ long locationId;
+ locationIdDictionary.TryGetValue(hrdLocationId, out locationId);
Assert.AreEqual(expectedLocationId, locationId);
}
Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile));
}
[Test]
- public void GetLocationId_AmbigousLocations_ReturnsFirstAndLogsWarning()
+ public void GetLocationsIdByRegionId_AmbigousLocations_ReturnsFirstAndLogsWarning()
{
// Setup
var dbFile = Path.Combine(testDataPath, "ambigousLocation.sqlite");
int regionId = 18;
int hrdLocationId = 1;
int expectedLocationId = 1800001;
string expectedMessage = "Er zijn meerdere resultaten gevonden, wat niet voor zou mogen komen. Neem contact op met de leverancier. Het eerste resultaat zal worden gebruikt.";
+ Dictionary locationIdDictionary = new Dictionary();
using (HydraulicLocationConfigurationSqLiteDatabaseReader hydraulicBoundarySqLiteDatabaseReader = new HydraulicLocationConfigurationSqLiteDatabaseReader(dbFile))
{
// Call
- var locationId = -1;
- Action call = () => locationId = hydraulicBoundarySqLiteDatabaseReader.GetLocationId(regionId, hrdLocationId);
+ Action call = () => locationIdDictionary = hydraulicBoundarySqLiteDatabaseReader.GetLocationsIdByRegionId(regionId);
// Assert
TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ long locationId;
+ locationIdDictionary.TryGetValue(hrdLocationId, out locationId);
Assert.AreEqual(expectedLocationId, locationId);
}
Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile));
}
[Test]
- public void GetLocationId_InvalidColumns_ThrowsLineParseException()
+ public void GetLocationsIdByRegionId_InvalidColumns_ThrowsLineParseException()
{
// Setup
var dbFile = Path.Combine(testDataPath, "corruptschema.sqlite");
var expectedMessage = new FileReaderErrorMessageBuilder(dbFile).Build(Resources.HydraulicBoundaryDatabaseReader_Critical_Unexpected_value_on_column);
int regionId = 1;
- int hrdLocationId = 1;
// Precondition
Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile), "Precondition: file can be opened for edits.");
using (HydraulicLocationConfigurationSqLiteDatabaseReader hydraulicBoundarySqLiteDatabaseReader = new HydraulicLocationConfigurationSqLiteDatabaseReader(dbFile))
{
// Call
- TestDelegate test = () => hydraulicBoundarySqLiteDatabaseReader.GetLocationId(regionId, hrdLocationId);
+ TestDelegate test = () => hydraulicBoundarySqLiteDatabaseReader.GetLocationsIdByRegionId(regionId);
// Assert
var exception = Assert.Throws(test);
@@ -137,21 +141,20 @@
}
[Test]
- public void GetLocationId_EmptyFile_ThrowsCriticalFileReadException()
+ public void GetLocationsIdByRegionId_EmptyFile_ThrowsCriticalFileReadException()
{
// Setup
var dbFile = Path.Combine(testDataPath, "empty.sqlite");
var expectedMessage = new FileReaderErrorMessageBuilder(dbFile).Build(Resources.HydraulicLocationConfigurationSqLiteDatabaseReader_Critical_Unexpected_Exception);
int regionId = 1;
- int hrdLocationId = 1;
// Precondition
Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile), "Precondition: file can be opened for edits.");
using (HydraulicLocationConfigurationSqLiteDatabaseReader hydraulicBoundarySqLiteDatabaseReader = new HydraulicLocationConfigurationSqLiteDatabaseReader(dbFile))
{
// Call
- TestDelegate test = () => hydraulicBoundarySqLiteDatabaseReader.GetLocationId(regionId, hrdLocationId);
+ TestDelegate test = () => hydraulicBoundarySqLiteDatabaseReader.GetLocationsIdByRegionId(regionId);
// Assert
var exception = Assert.Throws(test);
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/test-data/HydraulicBoundaryLocationReader/withoutHLCD/empty.sqlite
===================================================================
diff -u
Binary files differ
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/HydraulicBoundaryDatabaseImporter.cs
===================================================================
diff -u -rfc22f4b149d07797f0526f04ca58595bb9446786 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/HydraulicBoundaryDatabaseImporter.cs (.../HydraulicBoundaryDatabaseImporter.cs) (revision fc22f4b149d07797f0526f04ca58595bb9446786)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/HydraulicBoundaryDatabaseImporter.cs (.../HydraulicBoundaryDatabaseImporter.cs) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -39,8 +39,8 @@
///
public class HydraulicBoundaryDatabaseImporter : IDisposable
{
- private string hydraulicBoundaryDatabaseFilePath;
private readonly ILog log = LogManager.GetLogger(typeof(HydraulicBoundaryDatabaseImporter));
+ private string hydraulicBoundaryDatabaseFilePath;
private HydraulicBoundarySqLiteDatabaseReader hydraulicBoundaryDatabaseReader;
private HydraulicLocationConfigurationSqLiteDatabaseReader hydraulicLocationConfigurationDatabaseReader;
@@ -142,13 +142,16 @@
Version = hydraulicBoundaryDatabaseReader.GetVersion()
};
+ var locationidsDictionary = hydraulicLocationConfigurationDatabaseReader.GetLocationsIdByRegionId(regionId);
hydraulicBoundaryDatabaseReader.PrepareReadLocation();
while (hydraulicBoundaryDatabaseReader.HasNext)
{
try
{
HrdLocation hrdLocation = hydraulicBoundaryDatabaseReader.ReadLocation();
- var locationId = hydraulicLocationConfigurationDatabaseReader.GetLocationId(regionId, hrdLocation.HrdLocationId);
+
+ long locationId;
+ locationidsDictionary.TryGetValue(hrdLocation.HrdLocationId, out locationId);
var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(locationId, hrdLocation.Name, hrdLocation.LocationX, hrdLocation.LocationY);
hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation);
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs
===================================================================
diff -u -rfc22f4b149d07797f0526f04ca58595bb9446786 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision fc22f4b149d07797f0526f04ca58595bb9446786)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -22,7 +22,7 @@
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
+ public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
@@ -36,7 +36,7 @@
/// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
+ public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ringtoets.Integration.Plugin.Properties.Resources", typeof(Resources).Assembly);
@@ -51,7 +51,7 @@
/// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
+ public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
@@ -64,7 +64,7 @@
/// Looks up a localized string similar to {0}
///Er is geen vakindeling geïmporteerd..
///
- internal static string FailureMechanismSectionsImporter_CriticalErrorMessage_0_No_sections_imported {
+ public static string FailureMechanismSectionsImporter_CriticalErrorMessage_0_No_sections_imported {
get {
return ResourceManager.GetString("FailureMechanismSectionsImporter_CriticalErrorMessage_0_No_sections_imported", resourceCulture);
}
@@ -73,7 +73,7 @@
///
/// Looks up a localized string similar to Vakindeling importeren afgebroken. Geen data ingelezen..
///
- internal static string FailureMechanismSectionsImporter_Import_cancelled_no_data_read {
+ public static string FailureMechanismSectionsImporter_Import_cancelled_no_data_read {
get {
return ResourceManager.GetString("FailureMechanismSectionsImporter_Import_cancelled_no_data_read", resourceCulture);
}
@@ -82,7 +82,7 @@
///
/// Looks up a localized string similar to Vakkenindeling komt niet overeen met de huidige referentielijn..
///
- internal static string FailureMechanismSectionsImporter_Import_Imported_sections_do_not_correspond_to_current_referenceline {
+ public static string FailureMechanismSectionsImporter_Import_Imported_sections_do_not_correspond_to_current_referenceline {
get {
return ResourceManager.GetString("FailureMechanismSectionsImporter_Import_Imported_sections_do_not_correspond_to_cu" +
"rrent_referenceline", resourceCulture);
@@ -92,7 +92,7 @@
///
/// Looks up a localized string similar to Er is geen referentielijn beschikbaar om een vakindeling voor de definiëren..
///
- internal static string FailureMechanismSectionsImporter_Import_Required_reference_line_is_missing {
+ public static string FailureMechanismSectionsImporter_Import_Required_reference_line_is_missing {
get {
return ResourceManager.GetString("FailureMechanismSectionsImporter_Import_Required_reference_line_is_missing", resourceCulture);
}
@@ -101,7 +101,7 @@
///
/// Looks up a localized string similar to Er is geen referentielijn beschikbaar om een vakindeling voor de definiëren..
///
- internal static string FailureMechanismSectionsImporter_Import_Required_referenceline_missing {
+ public static string FailureMechanismSectionsImporter_Import_Required_referenceline_missing {
get {
return ResourceManager.GetString("FailureMechanismSectionsImporter_Import_Required_referenceline_missing", resourceCulture);
}
@@ -110,7 +110,7 @@
///
/// Looks up a localized string similar to Geïmporteerde data toevoegen aan het faalmechanisme..
///
- internal static string FailureMechanismSectionsImporter_ProgressText_Adding_imported_data_to_failureMechanism {
+ public static string FailureMechanismSectionsImporter_ProgressText_Adding_imported_data_to_failureMechanism {
get {
return ResourceManager.GetString("FailureMechanismSectionsImporter_ProgressText_Adding_imported_data_to_failureMech" +
"anism", resourceCulture);
@@ -120,7 +120,7 @@
///
/// Looks up a localized string similar to Inlezen vakindeling..
///
- internal static string FailureMechanismSectionsImporter_ProgressText_Reading_file {
+ public static string FailureMechanismSectionsImporter_ProgressText_Reading_file {
get {
return ResourceManager.GetString("FailureMechanismSectionsImporter_ProgressText_Reading_file", resourceCulture);
}
@@ -129,7 +129,7 @@
///
/// Looks up a localized string similar to Valideren ingelezen vakindeling..
///
- internal static string FailureMechanismSectionsImporter_ProgressText_Validating_imported_sections {
+ public static string FailureMechanismSectionsImporter_ProgressText_Validating_imported_sections {
get {
return ResourceManager.GetString("FailureMechanismSectionsImporter_ProgressText_Validating_imported_sections", resourceCulture);
}
@@ -138,7 +138,7 @@
///
/// Looks up a localized string similar to Het bestand heeft geen vakindeling..
///
- internal static string FailureMechanismSectionsImporter_ReadFile_File_is_empty {
+ public static string FailureMechanismSectionsImporter_ReadFile_File_is_empty {
get {
return ResourceManager.GetString("FailureMechanismSectionsImporter_ReadFile_File_is_empty", resourceCulture);
}
@@ -147,7 +147,7 @@
///
/// Looks up a localized string similar to {0} Het bestand wordt overgeslagen..
///
- internal static string HydraulicBoundaryDatabaseImporter_ErrorMessage_0_file_skipped {
+ public static string HydraulicBoundaryDatabaseImporter_ErrorMessage_0_file_skipped {
get {
return ResourceManager.GetString("HydraulicBoundaryDatabaseImporter_ErrorMessage_0_file_skipped", resourceCulture);
}
@@ -156,16 +156,16 @@
///
/// Looks up a localized string similar to Er is nog geen bestand geopend..
///
- internal static string HydraulicBoundaryDatabaseImporter_File_not_opened {
+ public static string HydraulicBoundaryDatabaseImporter_File_not_opened {
get {
return ResourceManager.GetString("HydraulicBoundaryDatabaseImporter_File_not_opened", resourceCulture);
}
}
///
- /// Looks up a localized string similar to Het bijbehorende HLCD.sqlite is niet gevonden in de folder..
+ /// Looks up a localized string similar to Het bijbehorende HLCD bestand is niet gevonden in de folder..
///
- internal static string HydraulicBoundaryDatabaseImporter_HLCD_sqlite_Not_Found {
+ public static string HydraulicBoundaryDatabaseImporter_HLCD_sqlite_Not_Found {
get {
return ResourceManager.GetString("HydraulicBoundaryDatabaseImporter_HLCD_sqlite_Not_Found", resourceCulture);
}
@@ -174,7 +174,7 @@
///
/// Looks up a localized string similar to De hydraulische randvoorwaarden locaties zijn ingelezen..
///
- internal static string HydraulicBoundaryDatabaseImporter_Import_All_hydraulic_locations_read {
+ public static string HydraulicBoundaryDatabaseImporter_Import_All_hydraulic_locations_read {
get {
return ResourceManager.GetString("HydraulicBoundaryDatabaseImporter_Import_All_hydraulic_locations_read", resourceCulture);
}
@@ -185,7 +185,7 @@
///
///Weet u zeker dat u wilt doorgaan?.
///
- internal static string ReferenceLineImporter_ConfirmImport_Confirm_referenceline_import_which_clears_data_when_performed {
+ public static string ReferenceLineImporter_ConfirmImport_Confirm_referenceline_import_which_clears_data_when_performed {
get {
return ResourceManager.GetString("ReferenceLineImporter_ConfirmImport_Confirm_referenceline_import_which_clears_dat" +
"a_when_performed", resourceCulture);
@@ -196,7 +196,7 @@
/// Looks up a localized string similar to {0}
///Er is geen referentielijn geïmporteerd..
///
- internal static string ReferenceLineImporter_HandleCriticalFileReadError_Error_0_no_referenceline_imported {
+ public static string ReferenceLineImporter_HandleCriticalFileReadError_Error_0_no_referenceline_imported {
get {
return ResourceManager.GetString("ReferenceLineImporter_HandleCriticalFileReadError_Error_0_no_referenceline_import" +
"ed", resourceCulture);
@@ -206,7 +206,7 @@
///
/// Looks up a localized string similar to Geïmporteerde data toevoegen aan het traject..
///
- internal static string ReferenceLineImporter_ProgressText_Adding_imported_referenceline_to_assessmentsection {
+ public static string ReferenceLineImporter_ProgressText_Adding_imported_referenceline_to_assessmentsection {
get {
return ResourceManager.GetString("ReferenceLineImporter_ProgressText_Adding_imported_referenceline_to_assessmentsec" +
"tion", resourceCulture);
@@ -216,7 +216,7 @@
///
/// Looks up a localized string similar to Referentielijn importeren afgebroken. Geen data ingelezen..
///
- internal static string ReferenceLineImporter_ProgressText_Import_cancelled_no_data_read {
+ public static string ReferenceLineImporter_ProgressText_Import_cancelled_no_data_read {
get {
return ResourceManager.GetString("ReferenceLineImporter_ProgressText_Import_cancelled_no_data_read", resourceCulture);
}
@@ -225,7 +225,7 @@
///
/// Looks up a localized string similar to Inlezen referentielijn..
///
- internal static string ReferenceLineImporter_ProgressText_Reading_referenceline {
+ public static string ReferenceLineImporter_ProgressText_Reading_referenceline {
get {
return ResourceManager.GetString("ReferenceLineImporter_ProgressText_Reading_referenceline", resourceCulture);
}
@@ -234,7 +234,7 @@
///
/// Looks up a localized string similar to Wissen rekenresultaten en vakindelingen van faalmechanismen..
///
- internal static string ReferenceLineImporter_ProgressText_Removing_calculation_output_and_failure_mechanism_sections {
+ public static string ReferenceLineImporter_ProgressText_Removing_calculation_output_and_failure_mechanism_sections {
get {
return ResourceManager.GetString("ReferenceLineImporter_ProgressText_Removing_calculation_output_and_failure_mechan" +
"ism_sections", resourceCulture);
@@ -244,7 +244,7 @@
///
/// Looks up a localized string similar to Verwijderen uitvoer van hydraulische randvoorwaarden..
///
- internal static string ReferenceLineImporter_ProgressText_Removing_hydraulic_boundary_output {
+ public static string ReferenceLineImporter_ProgressText_Removing_hydraulic_boundary_output {
get {
return ResourceManager.GetString("ReferenceLineImporter_ProgressText_Removing_hydraulic_boundary_output", resourceCulture);
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx
===================================================================
diff -u -rfc22f4b149d07797f0526f04ca58595bb9446786 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision fc22f4b149d07797f0526f04ca58595bb9446786)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -179,6 +179,6 @@
Geïmporteerde data toevoegen aan het faalmechanisme.
- Het bijbehorende HLCD.sqlite is niet gevonden in de folder.
+ Het bijbehorende HLCD bestand is niet gevonden in de folder.
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj
===================================================================
diff -u -rfcc49aac894f989182fb9faa487e50a585fbed03 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision fcc49aac894f989182fb9faa487e50a585fbed03)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -175,7 +175,7 @@
- ResXFileCodeGenerator
+ PublicResXFileCodeGenerator
Resources.Designer.cs
Designer
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/HydraulicBoundaryDatabaseImporterTest.cs
===================================================================
diff -u -rfc22f4b149d07797f0526f04ca58595bb9446786 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/HydraulicBoundaryDatabaseImporterTest.cs (.../HydraulicBoundaryDatabaseImporterTest.cs) (revision fc22f4b149d07797f0526f04ca58595bb9446786)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/HydraulicBoundaryDatabaseImporterTest.cs (.../HydraulicBoundaryDatabaseImporterTest.cs) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -23,21 +23,16 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-
using Core.Common.Base;
using Core.Common.IO.Exceptions;
using Core.Common.TestUtil;
-
+using Core.Common.Utils.Builders;
using NUnit.Framework;
-
using Rhino.Mocks;
-
using Ringtoets.Common.Data;
using Ringtoets.HydraRing.Data;
-using Ringtoets.Integration.Data;
using Ringtoets.Integration.Forms.PresentationObjects;
using Ringtoets.Integration.Plugin.FileImporters;
-
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
using RingtoetsFormsResources = Ringtoets.Common.Forms.Properties.Resources;
@@ -115,6 +110,21 @@
}
[Test]
+ public void ValidateAndConnectTo_ExistingFileWithoutHlcd_ThrowCriticalFileReadException()
+ {
+ // Setup
+ string validFilePath = Path.Combine(testDataPath, "withoutHLCD", "empty.sqlite");
+ string expectedMessage = new FileReaderErrorMessageBuilder(validFilePath).Build("Het bijbehorende HLCD bestand is niet gevonden in de folder.");
+
+ // Call
+ TestDelegate test = () => importer.ValidateAndConnectTo(validFilePath);
+
+ // Assert
+ CriticalFileReadException exception = Assert.Throws(test);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
public void GetHydraulicBoundaryDatabaseVersion_ValidFile_GetDatabaseVersion()
{
// Setup
@@ -146,6 +156,7 @@
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual(expectedMessage, exception.Message);
+ mocks.VerifyAll();
}
[Test]
@@ -180,6 +191,7 @@
Assert.AreEqual(18, importedLocations.Count);
CollectionAssert.AllItemsAreNotNull(importedLocations);
CollectionAssert.AllItemsAreUnique(importedLocations);
+ mocks.VerifyAll();
}
[Test]
@@ -212,5 +224,32 @@
mocks.VerifyAll(); // Expect no calls on 'observer'
}
+
+ [Test]
+ public void Import_CorruptSchemaFile_ReturnsFalse()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSectionMock = mocks.StrictMock();
+ var importTarget = mocks.StrictMock(assessmentSectionMock);
+ mocks.ReplayAll();
+
+ string validFilePath = Path.Combine(testDataPath, "corruptschema.sqlite");
+ string expectedMessage = new FileReaderErrorMessageBuilder(validFilePath)
+ .Build("Kritieke fout opgetreden bij het uitlezen van waardes uit kolommen in de database. Het bestand wordt overgeslagen.");
+ var importResult = true;
+
+ // Precondition
+ TestDelegate precondition = () => importer.ValidateAndConnectTo(validFilePath);
+ Assert.DoesNotThrow(precondition, "Precodition failed: ValidateAndConnectTo failed");
+
+ // Call
+ Action call = () => importResult = importer.Import(importTarget);
+
+ // Assert
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsFalse(importResult);
+ mocks.VerifyAll();
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj
===================================================================
diff -u -rfcc49aac894f989182fb9faa487e50a585fbed03 -ra77cd7f471b813c6a7218b42844d017fc10fb4ec
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision fcc49aac894f989182fb9faa487e50a585fbed03)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision a77cd7f471b813c6a7218b42844d017fc10fb4ec)
@@ -98,6 +98,10 @@
{e344867e-9ac9-44c8-88a5-8185681679a9}
Core.Common.IO
+
+ {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
+ Core.Common.Utils
+
{d749ee4c-ce50-4c17-bf01-9a953028c126}
Core.Common.TestUtil