Index: DamClients/DamUI/trunk/src/Dam/Tests/DataPluginImporterTests.cs =================================================================== diff -u -r2454 -r2470 --- DamClients/DamUI/trunk/src/Dam/Tests/DataPluginImporterTests.cs (.../DataPluginImporterTests.cs) (revision 2454) +++ DamClients/DamUI/trunk/src/Dam/Tests/DataPluginImporterTests.cs (.../DataPluginImporterTests.cs) (revision 2470) @@ -301,109 +301,6 @@ } } -// [Test] -// // WaterHeight must be specified in locations.csv, shapefile or scenarios.csv -// // If not specified in each of them, do not add the location and add message to log -// // In this test reading from shapefile is skipped -// public void WaterHeightIsRequired() -// { -// const double tolerance = 0.001; -// -// // Setup folder for situation where WaterHeight is specified -// var importFolder = Path.Combine(Directory.GetCurrentDirectory(), "TmpImportFilesWithWaterHeight"); -// if (!Directory.Exists(importFolder)) -// Directory.CreateDirectory(importFolder); -// srcDataSources = new List -// { -// new DataSource -// { -// DataSourceType = DataSourceType.CsvFiles, -// DataLocation = importFolder -// }, -// }; -// -// // To call ImportDataForDikeRings we need also inputfiles for segments, characteristic points etc. -// // To simplify the test we only import locations and scenario csv files -// // and then call AddScenarioDataToDikes like in ImportData -// -// // Create locations.csv that includes waterheight -// string importLocationsFile = importFolder + "\\locations.csv"; -// CreateLocationsFileWithWaterHeight(importLocationsFile); -// var csvImporterLocations = new CsvImporterLocations(importLocationsFile); -// var locationRecords = csvImporterLocations.ImportedItems; -// Assert.AreEqual(2, locationRecords.Count); -// Assert.AreEqual("RK210-560", locationRecords[0].LocationId); -// Assert.AreEqual("RK210-570", locationRecords[1].LocationId); -// // Expected: The locations include values for WaterHeight -// Assert.AreEqual(1.2, locationRecords[0].WaterHeight, tolerance); -// Assert.AreEqual(2.2, locationRecords[1].WaterHeight, tolerance); -// -// // Create scenarios.csv that does NOT include waterheight -// var importScenarioFile = importFolder + "\\scenarios.csv"; -// CreateScenariosFileWithoutWaterHeight(importScenarioFile); -// var csvImporterScenarios = new CsvImporterScenarios(importScenarioFile); -// var scenarioRecords = csvImporterScenarios.ImportedItems; -// Assert.AreEqual(2, scenarioRecords.Count); -// // Expected: Null because WaterHeight is not specified in scenarios -// Assert.AreEqual(null, scenarioRecords[0].WaterHeight); -// Assert.AreEqual(null, scenarioRecords[1].WaterHeight); -// // Combine the locations and scenario data -// var csvImporter = new CsvImporter(); -// csvImporter.LocationRecords = locationRecords; -// dataPluginImporter = new DataPluginImporter(); -// dataPluginImporter.SetDataSources("", srcDataSources); -// string dikeRingId = dataPluginImporter.GetDikeRingIdList().FirstOrDefault(); -// -// dataPluginImporter.AddCsvDataToDikes(csvImporter); -// dataPluginImporter.AddScenarioDataToDikes(csvImporter.ScenariosRecords); -// // Expected: The values of location are used for scenario -// string scenarioId = dataPluginImporter.GetScenarioList(dikeRingId, "RK210-560").FirstOrDefault(); -// IEnumerable scenarioDetails = dataPluginImporter.GetScenarioDetails(dikeRingId, "RK210-560", scenarioId); -// var nameValueParameters = scenarioDetails as NameValueParameter[] ?? scenarioDetails.ToArray(); -// Assert.AreEqual("1.2", nameValueParameters.FirstOrDefault(x => x.ParameterName.Equals("WaterHeight")).ParameterValue); -// scenarioId = dataPluginImporter.GetScenarioList(dikeRingId, "RK210-570").FirstOrDefault(); -// scenarioDetails = dataPluginImporter.GetScenarioDetails(dikeRingId, "RK210-570", scenarioId); -// nameValueParameters = scenarioDetails as NameValueParameter[] ?? scenarioDetails.ToArray(); -// Assert.AreEqual("2.2", nameValueParameters.FirstOrDefault(x => x.ParameterName.Equals("WaterHeight")).ParameterValue); -// -// // Create scenarios.csv that includes waterheight -// importScenarioFile = importFolder + "\\scenarios.csv"; -// CreateScenariosFileWithWaterHeight(importScenarioFile); -// csvImporterScenarios = new CsvImporterScenarios(importScenarioFile); -// scenarioRecords = csvImporterScenarios.ImportedItems; -// Assert.AreEqual(2, scenarioRecords.Count); -// // Expected: The value from scenarios are read -// Assert.AreEqual(0.1, scenarioRecords[0].WaterHeight, tolerance); -// Assert.AreEqual(0.2, scenarioRecords[1].WaterHeight, tolerance); -// // Combine the locations and scenario data -// csvImporter = new CsvImporter(); -// csvImporter.LocationRecords = locationRecords; -// dataPluginImporter = new DataPluginImporter(); -// dataPluginImporter.SetDataSources("", srcDataSources); -// dataPluginImporter.AddCsvDataToDikes(csvImporter); -// dataPluginImporter.AddScenarioDataToDikes(csvImporter.ScenariosRecords); -// // Expected: The values of scenarios are not overwritten by values from locations -//// Assert.AreEqual(0.1, scenarioRecords[0].WaterHeight, tolerance); -//// Assert.AreEqual(0.2, scenarioRecords[1].WaterHeight, tolerance); -// -// -// // // Read a locations.csv that does NOT include waterheight -// // importFile = importFolder + "\\locationsWithoutWaterheight.csv"; -// // CreateLocationsFileWithoutWaterHeight(importFile); -// // csvImporterLocations = new CsvImporterLocations(importFile); -// // locationRecords = csvImporterLocations.ImportedItems; -// // Assert.AreEqual(2, locationRecords.Count); -// // Assert.AreEqual("25-2-2-A-1-A", locationRecords[1].LocationId); -// // Assert.AreEqual(1.2, locationRecords[0].WaterHeight, tolerance); -// // Assert.AreEqual(2.2, locationRecords[1].WaterHeight, tolerance); -// // // Read a scenarios.csv that does NOT include waterheight -// // importFile = importFolder + "\\scenariosWithoutWaterheight.csv"; -// // CreateLocationsFileWithoutWaterHeight(importFile); -// // csvImporterLocations = new CsvImporterLocations(importFile); -// // locationRecords = csvImporterLocations.ImportedItems; -// // Assert.AreEqual(2, locationRecords.Count); -// } - [Test] // WaterHeight must be specified in locations.csv, shapefile or scenarios.csv // In this test reading from shapefile is skipped, WaterHeight is defined in locations, not in scenarios @@ -523,15 +420,17 @@ string dikeRingId = dataPluginImporter.GetDikeRingIdList().FirstOrDefault(); dataPluginImporter.ImportDataForDikeRings(new List { dikeRingId }, null); - // Expected: The values are null, the locations are deleted, error message for each location - string locations = dataPluginImporter.GetLocationIdList(dikeRingId).FirstOrDefault(); - Assert.AreEqual(null, locations); - // Expected: error message for each location, NB. messages start with last added locations first - Assert.AreEqual(2, dataPluginImporter.ImportLogMessages.Count); - Assert.AreEqual("Location 'RK210-570' not added, because water height is missing.", - dataPluginImporter.ImportLogMessages[0].Message); - Assert.AreEqual("Location 'RK210-560' not added, because water height is missing.", - dataPluginImporter.ImportLogMessages[1].Message); + // Expected: The values are null + string scenarioId = dataPluginImporter.GetScenarioList(dikeRingId, "RK210-560").FirstOrDefault(); + IEnumerable scenarioDetails = dataPluginImporter.GetScenarioDetails(dikeRingId, "RK210-560", scenarioId); + var nameValueParameters = scenarioDetails as NameValueParameter[] ?? scenarioDetails.ToArray(); + Assert.AreEqual(null, nameValueParameters.FirstOrDefault(x => x.ParameterName.Equals("RiverLevel")).ParameterValue); + scenarioId = dataPluginImporter.GetScenarioList(dikeRingId, "RK210-570").FirstOrDefault(); + scenarioDetails = dataPluginImporter.GetScenarioDetails(dikeRingId, "RK210-570", scenarioId); + nameValueParameters = scenarioDetails as NameValueParameter[] ?? scenarioDetails.ToArray(); + Assert.AreEqual(null, nameValueParameters.FirstOrDefault(x => x.ParameterName.Equals("RiverLevel")).ParameterValue); + // Expected: no error messages + Assert.AreEqual(0, dataPluginImporter.ImportLogMessages.Count); } } }