Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/StiImporter/SoilProfile2DImporterTest.cs =================================================================== diff -u -r4285 -r4292 --- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/StiImporter/SoilProfile2DImporterTest.cs (.../SoilProfile2DImporterTest.cs) (revision 4285) +++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/StiImporter/SoilProfile2DImporterTest.cs (.../SoilProfile2DImporterTest.cs) (revision 4292) @@ -168,7 +168,6 @@ [Test] public void Import_WithIncompleteSoilList_ThrowsSoilProfileImporterException() { - // Setup const string invalidSoilProfile = "Tutorial-1a 10.1.4.3.sti"; // Soil profile also contains peat and sand for its layers const string profileName = "SimpleProfile"; Segment segment = CreateSegmentWithProfiles(new[] @@ -182,18 +181,13 @@ "Muck" }); - // Call - TestDelegate call = () => SoilProfile2DImporter.Import(TestDataFolder, segment, availableSoils); - - // Assert - Assert.That(call, Throws.Exception.TypeOf() - .With.Message.EqualTo($"'{invalidSoilProfile}' contains undefined soils.")); + Assert.That(() => SoilProfile2DImporter.Import(TestDataFolder, segment, availableSoils), + Throws.Exception.TypeOf().With.Message.EqualTo($"'{invalidSoilProfile}' contains the undefined soil: Peat.")); } [Test] public void Import_WithSoilProfileCausingReadException_ThrowsSoilProfileImporterException() { - // Setup const string invalidSoilProfileName = "NonExistentSoilProfile"; Segment segment = CreateSegmentWithProfiles(new[] { Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/StiImporter/SoilProfile2DImporter.cs =================================================================== diff -u -r4285 -r4292 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/StiImporter/SoilProfile2DImporter.cs (.../SoilProfile2DImporter.cs) (revision 4285) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/StiImporter/SoilProfile2DImporter.cs (.../SoilProfile2DImporter.cs) (revision 4292) @@ -72,10 +72,11 @@ { string profileName = profile.SoilGeometry2DName; SoilProfile2D readSoilProfile = ReadSoilProfile(soilProfileDirectory, profileName); - if (!IsValidSoilProfile(availableSoils, readSoilProfile)) + string missingSoil = IsValidSoilProfile(availableSoils.Soils, readSoilProfile.Surfaces); + if (missingSoil != string.Empty) { string messageFormat = LocalizationManager.GetTranslatedText(typeof(SoilProfile2DImporter), "ImportSoilProfileErrorUndefinedMaterials"); - throw new SoilProfileImporterException(string.Format(messageFormat, profileName)); + throw new SoilProfileImporterException(string.Format(messageFormat, profileName, missingSoil)); } TransferSoilLayerProperties(readSoilProfile.Surfaces); @@ -143,10 +144,19 @@ return string.Equals(Path.GetExtension(profileName), ".sti", StringComparison.OrdinalIgnoreCase); } - private static bool IsValidSoilProfile(SoilList availableSoils, SoilProfile2D profile) + private static string IsValidSoilProfile(IEnumerable availableSoils, IEnumerable surfaces) { - var soilNames = new HashSet(availableSoils.Soils.Select(s => s.Name)); - return profile.Surfaces.All(soilLayer => soilNames.Contains(soilLayer.Name)); + var missingSoil = string.Empty; + var soilNames = new HashSet(availableSoils.Select(s => s.Name)); + foreach (string soilName in surfaces.Select(s => s.Soil.Name)) + { + if (!soilNames.Contains(soilName)) + { + missingSoil = soilName; + } + } + + return missingSoil; } private static void TransferSoilLayerProperties(IEnumerable soilLayers) Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Translations.xml =================================================================== diff -u -r4256 -r4292 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Translations.xml (.../Translations.xml) (revision 4256) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Translations.xml (.../Translations.xml) (revision 4292) @@ -827,8 +827,8 @@ - +