Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/CalculationGroupEntityReadExtentionsTest.cs =================================================================== diff -u -r811967790aed0c6617f36c2135016a5bc4aa8fcc -r3e7db9d95e07d438ec99f8488ec184848655b98c --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/CalculationGroupEntityReadExtentionsTest.cs (.../CalculationGroupEntityReadExtentionsTest.cs) (revision 811967790aed0c6617f36c2135016a5bc4aa8fcc) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/CalculationGroupEntityReadExtentionsTest.cs (.../CalculationGroupEntityReadExtentionsTest.cs) (revision 3e7db9d95e07d438ec99f8488ec184848655b98c) @@ -31,6 +31,7 @@ using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.HeightStructures.Data; using Ringtoets.Piping.Data; +using Ringtoets.StabilityPointStructures.Data; using Ringtoets.StabilityStoneCover.Data; using Ringtoets.WaveImpactAsphaltCover.Data; @@ -1033,6 +1034,199 @@ #endregion + #region StabilityPointStructures + + [Test] + public void ReadAsStabilityPointStructuresCalculationGroup_CollectorIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new CalculationGroupEntity(); + + // Call + TestDelegate call = () => entity.ReadAsStabilityPointStructuresCalculationGroup(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("collector", paramName); + } + + [Test] + [TestCase("HAbba")] + [TestCase("Dooeis")] + public void ReadAsStabilityPointStructuresCalculationGroup_EntityWithoutChildren_CreateCalculationGroupWithoutChildren(string name) + { + // Setup + var entity = new CalculationGroupEntity + { + Name = name, + }; + + var collector = new ReadConversionCollector(); + + // Call + CalculationGroup group = entity.ReadAsStabilityPointStructuresCalculationGroup(collector); + + // Assert + Assert.AreEqual(name, group.Name); + CollectionAssert.IsEmpty(group.Children); + } + + [Test] + public void ReadAsStabilityPointStructuresCalculationGroup_EntityWithChildGroups_CreateCalculationGroupWithChildGroups() + { + // Setup + var rootGroupEntity = new CalculationGroupEntity + { + Name = "A", + CalculationGroupEntity1 = + { + new CalculationGroupEntity + { + Name = "AB", + CalculationGroupEntity1 = + { + new CalculationGroupEntity + { + Name = "ABA", + Order = 0 + }, + new CalculationGroupEntity + { + Name = "ABB", + Order = 1 + } + }, + Order = 1 + }, + new CalculationGroupEntity + { + Name = "AA", + Order = 0 + } + } + }; + + var collector = new ReadConversionCollector(); + + // Call + var rootGroup = rootGroupEntity.ReadAsStabilityPointStructuresCalculationGroup(collector); + + // Assert + Assert.AreEqual("A", rootGroup.Name); + + ICalculationBase[] rootChildren = rootGroup.Children.ToArray(); + var rootChildGroup1 = (CalculationGroup)rootChildren[0]; + Assert.AreEqual("AA", rootChildGroup1.Name); + CollectionAssert.IsEmpty(rootChildGroup1.Children); + var rootChildGroup2 = (CalculationGroup)rootChildren[1]; + Assert.AreEqual("AB", rootChildGroup2.Name); + + ICalculationBase[] rootChildGroup2Children = rootChildGroup2.Children.ToArray(); + var rootChildGroup1Child1 = (CalculationGroup)rootChildGroup2Children[0]; + Assert.AreEqual("ABA", rootChildGroup1Child1.Name); + CollectionAssert.IsEmpty(rootChildGroup1Child1.Children); + var rootChildGroup1Child2 = (CalculationGroup)rootChildGroup2Children[1]; + Assert.AreEqual("ABB", rootChildGroup1Child2.Name); + CollectionAssert.IsEmpty(rootChildGroup1Child2.Children); + } + + [Test] + public void ReadAsStabilityPointStructuresCalculationGroup_EntityWithChildStabilityPointStructuresCalculations_CreateCalculationGroupWithChildCalculations() + { + // Setup + var rootGroupEntity = new CalculationGroupEntity + { + Name = "A", + StabilityPointStructuresCalculationEntities = + { + new StabilityPointStructuresCalculationEntity + { + Order = 0, + Name = "1" + }, + new StabilityPointStructuresCalculationEntity + { + Order = 1, + Name = "2" + } + } + }; + + var collector = new ReadConversionCollector(); + + // Call + var rootGroup = rootGroupEntity.ReadAsStabilityPointStructuresCalculationGroup(collector); + + // Assert + ICalculationBase[] rootChildren = rootGroup.Children.ToArray(); + Assert.AreEqual(2, rootChildren.Length); + + var rootChildCalculation1 = (StructuresCalculation)rootChildren[0]; + Assert.AreEqual("1", rootChildCalculation1.Name); + + var rootChildCalculation2 = (StructuresCalculation)rootChildren[1]; + Assert.AreEqual("2", rootChildCalculation2.Name); + } + + [Test] + public void ReadAsStabilityPointStructuresCalculationGroup_EntityWithChildStabilityPointStructuresCalculationAndGroups_CreateCalculationGroupWithChildCalculationsAndGroups() + { + // Setup + var rootGroupEntity = new CalculationGroupEntity + { + Name = "A", + StabilityPointStructuresCalculationEntities = + { + new StabilityPointStructuresCalculationEntity + { + Order = 0, + Name = "calculation1" + }, + new StabilityPointStructuresCalculationEntity + { + Order = 2, + Name = "calculation2" + } + }, + CalculationGroupEntity1 = + { + new CalculationGroupEntity + { + Order = 1, + Name = "group1" + }, + new CalculationGroupEntity + { + Order = 3, + Name = "group2" + } + } + }; + + var collector = new ReadConversionCollector(); + + // Call + var rootGroup = rootGroupEntity.ReadAsStabilityPointStructuresCalculationGroup(collector); + + // Assert + ICalculationBase[] rootChildren = rootGroup.Children.ToArray(); + Assert.AreEqual(4, rootChildren.Length); + + var rootChildCalculation1 = (StructuresCalculation)rootChildren[0]; + Assert.AreEqual("calculation1", rootChildCalculation1.Name); + + var rootChildGroup1 = (CalculationGroup)rootChildren[1]; + Assert.AreEqual("group1", rootChildGroup1.Name); + + var rootChildCalculation2 = (StructuresCalculation)rootChildren[2]; + Assert.AreEqual("calculation2", rootChildCalculation2.Name); + + var rootChildGroup2 = (CalculationGroup)rootChildren[3]; + Assert.AreEqual("group2", rootChildGroup2.Name); + } + + #endregion + #region Stability Stone Cover [Test]