Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/GeneralResultTest.cs =================================================================== diff -u -r383978e113c1829e86c866ac075a476fa7e07086 -rd7f56db6a475e07dd904bd61c0a56346aac4e565 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/GeneralResultTest.cs (.../GeneralResultTest.cs) (revision 383978e113c1829e86c866ac075a476fa7e07086) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/GeneralResultTest.cs (.../GeneralResultTest.cs) (revision d7f56db6a475e07dd904bd61c0a56346aac4e565) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Linq; using Core.Common.Data.TestUtil; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Data.TestUtil; @@ -103,17 +104,17 @@ } [Test] - public void Constructor_StochastNotUnique_ThrowArgumentException() + public void Constructor_StochastNamesNotUnique_ThrowArgumentException() { // Setup WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); var stochasts = new[] { - new Stochast("unique", 0, 0), - new Stochast("non-unique", 0, 0), - new Stochast("non-unique", 0, 0), - new Stochast("nonunique", 0, 0), - new Stochast("nonunique", 0, 0) + new Stochast("unique", 1, 4), + new Stochast("non-unique", 2, 0), + new Stochast("non-unique", 3, 2), + new Stochast("nonunique", 4, 0), + new Stochast("nonunique", 5, 1) }; IEnumerable topLevelIllustrationPoints = Enumerable.Empty(); @@ -124,22 +125,21 @@ topLevelIllustrationPoints); // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("Een of meerdere stochasten hebben dezelfde naam. " + - "Het uitlezen van illustratiepunten wordt overgeslagen.", - exception.Message); + const string expectedMessage = "Een of meerdere stochasten hebben dezelfde naam."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } [Test] - public void Constructor_TopLevelIllustrationPointsNotUnique_ThrowArgumentException() + public void Constructor_TopLevelIllustrationPointsWindDirectionClosingSituationCombinationNotUnique_ThrowArgumentException() { // Setup WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); IEnumerable stochasts = Enumerable.Empty(); + var topLevelIllustrationPoint = new TestTopLevelIllustrationPoint("not unique"); IEnumerable topLevelIllustrationPoints = new[] { - new TopLevelIllustrationPoint(new WindDirection("N", 0.5), "not unique"), - new TopLevelIllustrationPoint(new WindDirection("N", 0.5), "not unique") + topLevelIllustrationPoint, + topLevelIllustrationPoint }; // Call @@ -148,65 +148,39 @@ topLevelIllustrationPoints); // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("Een of meerdere illustratiepunten hebben dezelfde combinatie van sluitscenario en windrichting. " + - "Het uitlezen van illustratiepunten wordt overgeslagen.", - exception.Message); + const string expectedMessage = "Een of meerdere illustratiepunten hebben dezelfde combinatie van sluitscenario en windrichting."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } [Test] - public void Constructor_StochastsNotUnique_ThrowArgumentException() - { - // Setup - WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); - IEnumerable stochasts = new[] - { - new Stochast("Stochast 1", 0, 0), - new Stochast("Stochast 1", 0, 0) - }; - IEnumerable topLevelIllustrationPoints = new List(); - - // Call - TestDelegate test = () => new GeneralResult(windDirection, - stochasts, - topLevelIllustrationPoints); - - // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("Een of meerdere stochasten hebben dezelfde naam. " + - "Het uitlezen van illustratiepunten wordt overgeslagen.", - exception.Message); - } - - [Test] public void Constructor_ChildStochastsNotInStochasts_ThrowArgumentException() { // Setup WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); - IEnumerable stochasts = new[] + + var illustrationPointNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint(new[] { - new Stochast("Stochast 1", 0, 0) - }; - var illustrationPointNode = new IllustrationPointNode(new FaultTreeIllustrationPoint("A", 0.0, new [] - { new Stochast("Stochast 2", 0, 0) - }, CombinationType.And)); + })); IEnumerable topLevelIllustrationPoints = new List { - new TopLevelFaultTreeIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), "closing", illustrationPointNode) + new TopLevelFaultTreeIllustrationPoint(windDirection, "closing", illustrationPointNode) }; + IEnumerable stochasts = new[] + { + new Stochast("Stochast 1", 0, 0) + }; + // Call TestDelegate test = () => new GeneralResult(windDirection, stochasts, topLevelIllustrationPoints); // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als in de onderliggende illustratiepunten. " + - "Het uitlezen van illustratiepunten wordt overgeslagen.", - exception.Message); + const string expectedMessage = "De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als in de onderliggende illustratiepunten."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } [Test] @@ -236,11 +210,5 @@ // Assert CoreCloneAssert.AreObjectClones(original, clone, CommonCloneAssert.AreClones); } - - private class TopLevelIllustrationPoint : TopLevelIllustrationPointBase - { - public TopLevelIllustrationPoint(WindDirection windDirection, string closingSituation) - : base(windDirection, closingSituation) {} - } } } \ No newline at end of file