Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/IllustrationPointNodeCreateExtensions.cs
===================================================================
diff -u -r6c55d7ddb950eb8e434b9564367bffd9788876f8 -race63dd1e2a052cb8774347958f3f2e2013c7400
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/IllustrationPointNodeCreateExtensions.cs (.../IllustrationPointNodeCreateExtensions.cs) (revision 6c55d7ddb950eb8e434b9564367bffd9788876f8)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/IllustrationPointNodeCreateExtensions.cs (.../IllustrationPointNodeCreateExtensions.cs) (revision ace63dd1e2a052cb8774347958f3f2e2013c7400)
@@ -44,7 +44,7 @@
/// A new .
/// Thrown when
/// is null.
- /// Thrown when
+ /// Thrown when
/// is not of type .
public static FaultTreeIllustrationPointEntity Create(
this IllustrationPointNode illustrationPointNode,
@@ -58,7 +58,7 @@
var faultTreeIllustrationPoint = illustrationPointNode.Data as FaultTreeIllustrationPoint;
if (faultTreeIllustrationPoint == null)
{
- throw new InvalidOperationException($"Illustration point type '{illustrationPointNode.Data.GetType()}' is not supported.");
+ throw new NotSupportedException($"Illustration point type '{illustrationPointNode.Data.GetType()}' is not supported.");
}
FaultTreeIllustrationPointEntity entity = CreateFaultTreeIllustrationPoint(faultTreeIllustrationPoint,
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/FaultTreeIllustrationPointEntityReadExtensions.cs
===================================================================
diff -u -r70dd51c2b1d7239cc5cf4e929017308fe64e5aa9 -race63dd1e2a052cb8774347958f3f2e2013c7400
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/FaultTreeIllustrationPointEntityReadExtensions.cs (.../FaultTreeIllustrationPointEntityReadExtensions.cs) (revision 70dd51c2b1d7239cc5cf4e929017308fe64e5aa9)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/FaultTreeIllustrationPointEntityReadExtensions.cs (.../FaultTreeIllustrationPointEntityReadExtensions.cs) (revision ace63dd1e2a052cb8774347958f3f2e2013c7400)
@@ -105,9 +105,7 @@
private static CombinationType GetCombinationType(FaultTreeIllustrationPointEntity entity)
{
- return entity.CombinationType == (byte) CombinationType.And
- ? CombinationType.And
- : CombinationType.Or;
+ return (CombinationType) entity.CombinationType;
}
private static IEnumerable GetReadStochasts(IEnumerable stochastEntities)
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/GeneralResultFaultTreeIllustrationPointEntityReadExtensions.cs
===================================================================
diff -u -r283d7e09d084caafac590fdf96bfc6a264604016 -race63dd1e2a052cb8774347958f3f2e2013c7400
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/GeneralResultFaultTreeIllustrationPointEntityReadExtensions.cs (.../GeneralResultFaultTreeIllustrationPointEntityReadExtensions.cs) (revision 283d7e09d084caafac590fdf96bfc6a264604016)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/GeneralResultFaultTreeIllustrationPointEntityReadExtensions.cs (.../GeneralResultFaultTreeIllustrationPointEntityReadExtensions.cs) (revision ace63dd1e2a052cb8774347958f3f2e2013c7400)
@@ -54,12 +54,12 @@
IEnumerable stochasts = GetReadStochasts(entity.StochastEntities);
- IEnumerable illustrationPoints =
+ IEnumerable topLevelIllustrationPoints =
GetReadTopLevelFaultTreeIllustrationPoint(entity.TopLevelFaultTreeIllustrationPointEntities);
return new GeneralResult(governingWindDirection,
stochasts,
- illustrationPoints);
+ topLevelIllustrationPoints);
}
private static WindDirection GetGoverningWindDirection(IGeneralResultEntity entity)
@@ -75,10 +75,10 @@
}
private static IEnumerable GetReadTopLevelFaultTreeIllustrationPoint(
- IEnumerable illustrationPointEntities)
+ IEnumerable topLevelIllustrationPointEntities)
{
- return illustrationPointEntities.OrderBy(ip => ip.Order)
- .Select(ip => ip.Read());
+ return topLevelIllustrationPointEntities.OrderBy(ip => ip.Order)
+ .Select(ip => ip.Read());
}
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/GeneralResultSubMechanismIllustrationPointEntityReadExtensions.cs
===================================================================
diff -u -r283d7e09d084caafac590fdf96bfc6a264604016 -race63dd1e2a052cb8774347958f3f2e2013c7400
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/GeneralResultSubMechanismIllustrationPointEntityReadExtensions.cs (.../GeneralResultSubMechanismIllustrationPointEntityReadExtensions.cs) (revision 283d7e09d084caafac590fdf96bfc6a264604016)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/GeneralResultSubMechanismIllustrationPointEntityReadExtensions.cs (.../GeneralResultSubMechanismIllustrationPointEntityReadExtensions.cs) (revision ace63dd1e2a052cb8774347958f3f2e2013c7400)
@@ -55,12 +55,12 @@
IEnumerable stochasts = GetReadStochasts(entity.StochastEntities);
- IEnumerable illustrationPoints =
+ IEnumerable topLevelIllustrationPoints =
GetReadTopLevelSubMechanismIllustrationPoint(entity.TopLevelSubMechanismIllustrationPointEntities);
return new GeneralResult(governingWindDirection,
stochasts,
- illustrationPoints);
+ topLevelIllustrationPoints);
}
private static WindDirection GetGoverningWindDirection(IGeneralResultEntity entity)
@@ -76,10 +76,10 @@
}
private static IEnumerable GetReadTopLevelSubMechanismIllustrationPoint(
- IEnumerable illustrationPointEntities)
+ IEnumerable topLevelIllustrationPointEntities)
{
- return illustrationPointEntities.OrderBy(ip => ip.Order)
- .Select(ip => ip.Read());
+ return topLevelIllustrationPointEntities.OrderBy(ip => ip.Order)
+ .Select(ip => ip.Read());
}
}
}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -raa49537188229065df91b1a931f088c32115702a -race63dd1e2a052cb8774347958f3f2e2013c7400
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision aa49537188229065df91b1a931f088c32115702a)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision ace63dd1e2a052cb8774347958f3f2e2013c7400)
@@ -97,7 +97,7 @@
-
+
Code
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/GeneralResultCreateExtensionsTest.cs
===================================================================
diff -u -r6c55d7ddb950eb8e434b9564367bffd9788876f8 -race63dd1e2a052cb8774347958f3f2e2013c7400
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/GeneralResultCreateExtensionsTest.cs (.../GeneralResultCreateExtensionsTest.cs) (revision 6c55d7ddb950eb8e434b9564367bffd9788876f8)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/GeneralResultCreateExtensionsTest.cs (.../GeneralResultCreateExtensionsTest.cs) (revision ace63dd1e2a052cb8774347958f3f2e2013c7400)
@@ -279,6 +279,7 @@
TestHelper.AssertAreEqualButNotSame(expectedWindDirection.Name, illustrationPointEntity.WindDirectionName);
Assert.AreEqual(expectedWindDirection.Angle, illustrationPointEntity.WindDirectionAngle,
expectedWindDirection.Angle.GetAccuracy());
+ TestHelper.AssertAreEqualButNotSame(illustrationPoint.ClosingSituation, illustrationPointEntity.ClosingSituation);
Assert.AreEqual(expectedOrder, illustrationPointEntity.Order);
}
@@ -311,6 +312,7 @@
TestHelper.AssertAreEqualButNotSame(expectedWindDirection.Name, illustrationPointEntity.WindDirectionName);
Assert.AreEqual(expectedWindDirection.Angle, illustrationPointEntity.WindDirectionAngle,
expectedWindDirection.Angle.GetAccuracy());
+ TestHelper.AssertAreEqualButNotSame(illustrationPoint.ClosingSituation, illustrationPointEntity.ClosingSituation);
Assert.AreEqual(expectedOrder, illustrationPointEntity.Order);
}
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/IllustrationPointNodeCreateExtensionsTest.cs
===================================================================
diff -u -r79565e60750c8a6c33847cd94d5c5910b77542b1 -race63dd1e2a052cb8774347958f3f2e2013c7400
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/IllustrationPointNodeCreateExtensionsTest.cs (.../IllustrationPointNodeCreateExtensionsTest.cs) (revision 79565e60750c8a6c33847cd94d5c5910b77542b1)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/IllustrationPointNodeCreateExtensionsTest.cs (.../IllustrationPointNodeCreateExtensionsTest.cs) (revision ace63dd1e2a052cb8774347958f3f2e2013c7400)
@@ -110,16 +110,15 @@
CollectionAssert.IsEmpty(entity.TopLevelFaultTreeIllustrationPointEntities);
Assert.AreEqual(order, entity.Order);
- StochastEntity entityStochastEntity = entity.StochastEntities.FirstOrDefault();
- Assert.IsNotNull(entityStochastEntity);
+ StochastEntity entityStochastEntity = entity.StochastEntities.Single();
Stochast stochast = illustrationPoint.Stochasts.First();
Assert.AreEqual(stochast.Name, entityStochastEntity.Name);
Assert.AreEqual(stochast.Alpha, entityStochastEntity.Alpha);
Assert.AreEqual(stochast.Duration, entityStochastEntity.Duration);
}
[Test]
- public void Create_IllustrationPointNodeWithSubMechanismIllustrationPoint_ThrowsInvalidOperationException()
+ public void Create_IllustrationPointNodeWithSubMechanismIllustrationPoint_ThrowsNotSupportedException()
{
// Setup
var node = new IllustrationPointNode(new TestSubMechanismIllustrationPoint());
@@ -128,7 +127,7 @@
TestDelegate call = () => node.Create(0);
// Assert
- string message = Assert.Throws(call).Message;
+ string message = Assert.Throws(call).Message;
Assert.AreEqual($"Illustration point type '{typeof(TestSubMechanismIllustrationPoint)}' is not supported.", message);
}
@@ -192,17 +191,20 @@
{
new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()),
node
- }).SetName("IllustrationPointsWithChildren");
+ }).SetName("FaultTreeIllustrationPointsWithChildren");
}
private static void AssertIllustrationPointEntities(
IllustrationPointNode[] children,
- IList subMechanismIllustrationPointEntities,
- IList faultTreeIllustrationPointEntity
+ IEnumerable subMechanismIllustrationPointEntities,
+ IEnumerable faultTreeIllustrationPointEntity
)
{
for (var i = 0; i < children.Length; i++)
{
+ int nrOfTotalCreatedEntities = subMechanismIllustrationPointEntities.Count() + faultTreeIllustrationPointEntity.Count();
+ Assert.AreEqual(nrOfTotalCreatedEntities, children.Length);
+
IllustrationPointNode child = children[i];
var subMechanismIllustrationPoint = child.Data as SubMechanismIllustrationPoint;
@@ -231,6 +233,9 @@
Assert.IsNotNull(illustrationPoint);
Assert.AreEqual(illustrationPoint.Beta, illustrationPointEntity.Beta, illustrationPoint.Beta.GetAccuracy());
TestHelper.AssertAreEqualButNotSame(illustrationPoint.Name, illustrationPointEntity.Name);
+
+ CollectionAssert.IsEmpty(illustrationPointEntity.IllustrationPointResultEntities);
+ CollectionAssert.IsEmpty(illustrationPointEntity.SubMechanismIllustrationPointStochastEntities);
}
private static void AssertFaultTreeIllustrationPointEntity(FaultTreeIllustrationPoint illustrationPoint,
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/TopLevelFaultTreeIllustrationPointCreateExtensionsTest.cs
===================================================================
diff -u -rc4289bccc81c65f0b9972d1e2d073aae31820fbf -race63dd1e2a052cb8774347958f3f2e2013c7400
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/TopLevelFaultTreeIllustrationPointCreateExtensionsTest.cs (.../TopLevelFaultTreeIllustrationPointCreateExtensionsTest.cs) (revision c4289bccc81c65f0b9972d1e2d073aae31820fbf)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/TopLevelFaultTreeIllustrationPointCreateExtensionsTest.cs (.../TopLevelFaultTreeIllustrationPointCreateExtensionsTest.cs) (revision ace63dd1e2a052cb8774347958f3f2e2013c7400)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Linq;
using Application.Ringtoets.Storage.Create.IllustrationPoints;
using Application.Ringtoets.Storage.DbContext;
using Core.Common.TestUtil;
@@ -64,7 +65,39 @@
TestHelper.AssertAreEqualButNotSame(illustrationPoint.ClosingSituation, entity.ClosingSituation);
TestHelper.AssertAreEqualButNotSame(windDirection.Name, entity.WindDirectionName);
Assert.AreEqual(windDirection.Angle, entity.WindDirectionAngle, windDirection.Angle.GetAccuracy());
+ CollectionAssert.IsEmpty(illustrationPoint.FaultTreeNodeRoot.Children);
Assert.AreEqual(order, entity.Order);
}
+
+ [Test]
+ public void Create_ValidTopLevelFaultTreeIllustrationPointWithChildren_ReturnsTopLevelFaultTreeIllustrationPointEntityWithChildren()
+ {
+ // Setup
+ var random = new Random(21);
+
+ var windDirection = new WindDirection("WindDirection Name", random.NextDouble());
+ var topLevelIllustrationPoint = new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint());
+ topLevelIllustrationPoint.SetChildren(new[]
+ {
+ new IllustrationPointNode(new TestSubMechanismIllustrationPoint()),
+ new IllustrationPointNode(new TestSubMechanismIllustrationPoint())
+ });
+
+ var illustrationPoint = new TopLevelFaultTreeIllustrationPoint(
+ windDirection,
+ "Just a situation",
+ topLevelIllustrationPoint);
+ int order = random.Next();
+
+ // Call
+ TopLevelFaultTreeIllustrationPointEntity entity = illustrationPoint.Create(order);
+
+ // Assert
+ TestHelper.AssertAreEqualButNotSame(illustrationPoint.ClosingSituation, entity.ClosingSituation);
+ TestHelper.AssertAreEqualButNotSame(windDirection.Name, entity.WindDirectionName);
+ Assert.AreEqual(windDirection.Angle, entity.WindDirectionAngle, windDirection.Angle.GetAccuracy());
+ Assert.AreEqual(2, entity.FaultTreeIllustrationPointEntity.SubMechanismIllustrationPointEntities.Count);
+ Assert.AreEqual(order, entity.Order);
+ }
}
}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/TopLevelSubMechanismIllustrationPointCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/TopLevelSubMechanismIllustrationPointCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/TopLevelSubMechanismIllustrationPointCreateExtensionsTest.cs (revision ace63dd1e2a052cb8774347958f3f2e2013c7400)
@@ -0,0 +1,81 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Linq;
+using NUnit.Framework;
+using Application.Ringtoets.Storage.Create.IllustrationPoints;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.TestUtil;
+using Ringtoets.Common.Data.IllustrationPoints;
+using Ringtoets.Common.Data.TestUtil;
+
+namespace Application.Ringtoets.Storage.Test.Create.IllustrationPoints
+{
+ [TestFixture]
+ public class TopLevelSubMechanismIllustrationPointCreateExtensionsTest
+ {
+ [Test]
+ public void Create_TopLevelSubMechanismIllustrationPointNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((TopLevelSubMechanismIllustrationPoint) null).Create(0);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("topLevelSubMechanismIllustrationPoint", exception.ParamName);
+ }
+
+ [Test]
+ public void Create_ValidTopLevelSubMechanismIllustrationPoint_ReturnsEntityWithSubMechanismIllustrationPointEntity()
+ {
+ // Setup
+ var random = new Random(21);
+ var illustrationPoint = new SubMechanismIllustrationPoint("Illustration point name",
+ random.NextDouble(),
+ Enumerable.Empty(),
+ Enumerable.Empty());
+
+ var windDirection = new WindDirection("WindDirection Name", random.NextDouble());
+ var topLevelSubMechanismIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(windDirection,
+ "Just a situation",
+ illustrationPoint);
+ int order = random.Next();
+
+ // Call
+ TopLevelSubMechanismIllustrationPointEntity entity =
+ topLevelSubMechanismIllustrationPoint.Create(order);
+
+ // Assert
+ TestHelper.AssertAreEqualButNotSame(topLevelSubMechanismIllustrationPoint.ClosingSituation, entity.ClosingSituation);
+ Assert.AreEqual(order, entity.Order);
+
+ TestHelper.AssertAreEqualButNotSame(windDirection.Name, entity.WindDirectionName);
+ Assert.AreEqual(windDirection.Angle, entity.WindDirectionAngle, windDirection.Angle.GetAccuracy());
+
+ SubMechanismIllustrationPointEntity subMechanismIllustrationPointEntity = entity.SubMechanismIllustrationPointEntity;
+ TestHelper.AssertAreEqualButNotSame(illustrationPoint.Name, subMechanismIllustrationPointEntity.Name);
+ Assert.AreEqual(illustrationPoint.Beta, subMechanismIllustrationPointEntity.Beta, illustrationPoint.Beta.GetAccuracy());
+ CollectionAssert.IsEmpty(subMechanismIllustrationPointEntity.IllustrationPointResultEntities);
+ CollectionAssert.IsEmpty(subMechanismIllustrationPointEntity.SubMechanismIllustrationPointStochastEntities);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag ace63dd1e2a052cb8774347958f3f2e2013c7400 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/TopLevelSubMechanismIllustrationPointTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?