Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResult.cs =================================================================== diff -u -r90c8c7af20b188d787a29c8e5fcd03823009f209 -re0c69303985f5ad57106c5b7f18700d1a16ae3b3 --- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResult.cs (.../GeneralResult.cs) (revision 90c8c7af20b188d787a29c8e5fcd03823009f209) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResult.cs (.../GeneralResult.cs) (revision e0c69303985f5ad57106c5b7f18700d1a16ae3b3) @@ -22,6 +22,8 @@ using System; using System.Collections.Generic; using System.Linq; +using Core.Common.Utils.Extensions; +using Ringtoets.Common.Data.Properties; namespace Ringtoets.Common.Data.IllustrationPoints { @@ -59,6 +61,9 @@ throw new ArgumentNullException(nameof(topLevelIllustrationPoints)); } + ValidateStochasts(stochasts); + ValidateTopLevelIllustrationPoints(topLevelIllustrationPoints); + GoverningWindDirection = governingWindDirection; Stochasts = stochasts; TopLevelIllustrationPoints = topLevelIllustrationPoints; @@ -89,5 +94,24 @@ return clone; } + + private static void ValidateTopLevelIllustrationPoints(IEnumerable topLevelIllustrationPoints) + { + bool hasNonDistinctIllustrationPointsPerWindDirection = + topLevelIllustrationPoints.AnyNonDistinct(t => $"{t.ClosingSituation} {t.WindDirection.Angle}"); + if (hasNonDistinctIllustrationPointsPerWindDirection) + { + throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_non_unique_closing_situations_or_wind_direction)); + } + } + + private static void ValidateStochasts(IEnumerable stochasts) + { + bool hasNonDistinctStochasts = stochasts.AnyNonDistinct(s => s.Name); + if (hasNonDistinctStochasts) + { + throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_non_unique_stochasts)); + } + } } } \ No newline at end of file