Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelTest.cs =================================================================== diff -u -r303f3924f66df0bc726646b29031a926a94882bc -r56ac4eb28f5fcc5b20117474e9e4030399d6806a --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelTest.cs (.../StochasticSoilModelTest.cs) (revision 303f3924f66df0bc726646b29031a926a94882bc) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelTest.cs (.../StochasticSoilModelTest.cs) (revision 56ac4eb28f5fcc5b20117474e9e4030399d6806a) @@ -368,6 +368,42 @@ } [Test] + public void Update_ModelsWithAddedProfilesWithSameNames_ThrowsInvalidOperationException() + { + // Setup + var addedProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3) + { + SoilProfile = new TestPipingSoilProfile() + }; + StochasticSoilModel otherModel = CreateEmptyModel(); + otherModel.StochasticSoilProfiles.Add(addedProfile); + + var existingProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3) + { + SoilProfile = new TestPipingSoilProfile() + }; + StochasticSoilModel model = CreateEmptyModel(); + model.StochasticSoilProfiles.Add(existingProfile); + model.StochasticSoilProfiles.Add(existingProfile); + + // Call + TestDelegate call = () => model.Update(otherModel); + + // Assert + Assert.Throws(call); + + Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count); + Assert.AreEqual(addedProfile, otherModel.StochasticSoilProfiles[0]); + + Assert.AreEqual(2, model.StochasticSoilProfiles.Count); + CollectionAssert.AreEqual(new[] + { + existingProfile, + existingProfile + }, model.StochasticSoilProfiles); + } + + [Test] [TestCase(null)] [TestCase("")] [TestCase("some name")]