public void ChildNodeObjects_ChartDataCollection_ReturnsItemsFromChartDataCollectionList()
        {
            // Setup
            var chartData1          = new TestChartData();
            var chartData2          = new TestChartData();
            var chartData3          = new TestChartData();
            var chartDataCollection = new ChartDataCollection("test");

            chartDataCollection.Add(chartData1);
            chartDataCollection.Add(chartData2);
            chartDataCollection.Add(chartData3);

            ChartDataContext context = GetContext(chartDataCollection);

            // Call
            object[] objects = info.ChildNodeObjects(context);

            // Assert
            var expectedChildren = new[]
            {
                new ChartDataContext(chartData3, new ChartDataCollection("test")),
                new ChartDataContext(chartData2, new ChartDataCollection("test")),
                new ChartDataContext(chartData1, new ChartDataCollection("test"))
            };

            CollectionAssert.AreEqual(expectedChildren, objects);
        }
Пример #2
0
        public void ChildNodeObjects_WithoutFailureMechanisms_ReturnChildDataNodes()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanisms = new ObservableList <SpecificFailureMechanism>();
            var context           = new SpecificFailureMechanismsContext(failureMechanisms, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(context).ToArray();

            // Assert
            CollectionAssert.IsEmpty(children);
        }
Пример #3
0
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            mocks.ReplayAll();

            var object1            = new object();
            var object2            = new object();
            var categoryTreeFolder = new CategoryTreeFolder("", new[]
            {
                object1,
                object2
            });

            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] objects = info.ChildNodeObjects(categoryTreeFolder);

                // Assert
                CollectionAssert.AreEqual(new[]
                {
                    object1,
                    object2
                }, objects);
            }

            mocks.VerifyAll();
        }
        public void ChildNodeObjects_Always_ReturnsChildrenWithContextAndDataReversed()
        {
            // Setup
            var mapPointData      = new MapPointData("points");
            var mapLineData       = new MapLineData("lines");
            var nestedCollection  = new MapDataCollection("nested");
            var mapPolygonData    = new MapPolygonData("polygons");
            var mapDataCollection = new MapDataCollection("test data");

            mapDataCollection.Add(mapPointData);
            mapDataCollection.Add(mapLineData);
            mapDataCollection.Add(nestedCollection);
            mapDataCollection.Add(mapPolygonData);

            MapDataCollectionContext parentCollectionContext = GetContext(mapDataCollection);

            // Call
            object[] objects = info.ChildNodeObjects(GetContext(mapDataCollection));

            // Assert
            CollectionAssert.AreEqual(new MapDataContext[]
            {
                new MapPolygonDataContext(mapPolygonData, parentCollectionContext),
                GetContext(nestedCollection, parentCollectionContext),
                new MapLineDataContext(mapLineData, parentCollectionContext),
                new MapPointDataContext(mapPointData, parentCollectionContext)
            }, objects);
        }
        public void ChildNodeObjects_WithContext_ReturnChildDataNodes()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();

            var failureMechanism = new DuneErosionFailureMechanism();
            var context          = new DuneErosionFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(context).ToArray();

            // Assert
            Assert.AreEqual(2, children.Length);

            var inputsFolder = (CategoryTreeFolder)children[0];

            Assert.AreEqual("Invoer", inputsFolder.Name);
            Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category);

            Assert.AreEqual(1, inputsFolder.Contents.Count());
            var calculationsInputComments = (Comment)inputsFolder.Contents.ElementAt(0);

            Assert.AreSame(failureMechanism.CalculationsInputComments, calculationsInputComments);

            var targetProbabilitiesGroupContext = (DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext)children[1];

            Assert.AreSame(failureMechanism.DuneLocationCalculationsForUserDefinedTargetProbabilities, targetProbabilitiesGroupContext.WrappedData);
            Assert.AreSame(failureMechanism, targetProbabilitiesGroupContext.FailureMechanism);
            Assert.AreSame(assessmentSection, targetProbabilitiesGroupContext.AssessmentSection);
        }
        public void ChildNodeObjects_FailureMechanismInAssemblyFalse_ReturnChildDataNodes()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new DuneErosionFailureMechanism
            {
                InAssembly = false
            };
            var context = new DuneErosionFailureMechanismContext(failureMechanism, assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] children = info.ChildNodeObjects(context).ToArray();

                // Assert
                Assert.AreEqual(1, children.Length);

                var comment = (Comment)children[0];
                Assert.AreSame(failureMechanism.NotInAssemblyComments, comment);
            }

            mocks.VerifyAll();
        }
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
            var context           = new RegistrationStateRootContext(assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] objects = info.ChildNodeObjects(context).ToArray();

                // Assert
                Assert.AreEqual(4, objects.Length);

                var assemblyGroupsContext = (FailureMechanismSectionAssemblyGroupsContext)objects[0];
                Assert.AreSame(assessmentSection, assemblyGroupsContext.WrappedData);

                var genericFailureMechanismsContext = (GenericFailureMechanismsContext)objects[1];
                Assert.AreSame(assessmentSection, genericFailureMechanismsContext.WrappedData);

                var specificFailureMechanismsContext = (SpecificFailureMechanismsContext)objects[2];
                Assert.AreSame(assessmentSection.SpecificFailureMechanisms, specificFailureMechanismsContext.WrappedData);
                Assert.AreSame(assessmentSection, specificFailureMechanismsContext.AssessmentSection);

                var assemblyResultsContext = (AssemblyResultsContext)objects[3];
                Assert.AreSame(assessmentSection, assemblyResultsContext.WrappedData);
            }
        }
Пример #8
0
        public void ChildNodeObjects_Always_ReturnClosingStructures()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            ClosingStructure closingStructure1 = new TestClosingStructure("structure1");
            ClosingStructure closingStructure2 = new TestClosingStructure("structure2");
            var failureMechanism = new ClosingStructuresFailureMechanism();

            failureMechanism.ClosingStructures.AddRange(new[]
            {
                closingStructure1,
                closingStructure2
            }, "some path");

            var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(closingStructuresContext);

            // Assert
            Assert.AreEqual(2, children.Length);
            Assert.AreSame(closingStructure1, children.ElementAt(0));
            Assert.AreSame(closingStructure2, children.ElementAt(1));
            mocks.VerifyAll();
        }
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var stochasticSoilProfile1 = new MacroStabilityInwardsStochasticSoilProfile(
                1.0,
                new MacroStabilityInwardsSoilProfile1D("soilProfile1", 0, new List <MacroStabilityInwardsSoilLayer1D>
            {
                new MacroStabilityInwardsSoilLayer1D(10)
            }));
            var stochasticSoilProfile2 = new MacroStabilityInwardsStochasticSoilProfile(
                1.0,
                new MacroStabilityInwardsSoilProfile1D("soilProfile2", 0, new List <MacroStabilityInwardsSoilLayer1D>
            {
                new MacroStabilityInwardsSoilLayer1D(10)
            }));

            MacroStabilityInwardsStochasticSoilModel stochasticSoilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("SoilModel", new[]
            {
                stochasticSoilProfile1,
                stochasticSoilProfile2
            });

            // Call
            object[] objects = info.ChildNodeObjects(stochasticSoilModel);

            // Assert
            MacroStabilityInwardsStochasticSoilProfile[] expectedChildren =
            {
                stochasticSoilProfile1,
                stochasticSoilProfile2
            };
            CollectionAssert.AreEqual(expectedChildren, objects);
        }
Пример #10
0
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection  = mocks.Stub <IAssessmentSection>();
            var pipingSurfaceLine1 = new PipingSurfaceLine("Line A");
            var pipingSurfaceLine2 = new PipingSurfaceLine("Line B");

            var surfaceLines = new PipingSurfaceLineCollection();

            surfaceLines.AddRange(new[]
            {
                pipingSurfaceLine1,
                pipingSurfaceLine2
            }, "path");

            var failureMechanism = new PipingFailureMechanism();

            var pipingSurfaceLineContext = new PipingSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            mocks.ReplayAll();

            // Call
            object[] objects = info.ChildNodeObjects(pipingSurfaceLineContext);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                pipingSurfaceLine1,
                pipingSurfaceLine2
            }, objects);
        }
        public void ChildNodeObjects_Always_ReturnsCollectionWithOutputObjects(bool hasOutput)
        {
            // Setup
            var grassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation
            {
                Output = hasOutput ? new TestGrassCoverErosionInwardsOutput() : null
            };
            var grassCoverErosionInwardsOutputContext = new GrassCoverErosionInwardsOutputContext(grassCoverErosionInwardsCalculation);

            // Call
            object[] children = info.ChildNodeObjects(grassCoverErosionInwardsOutputContext).ToArray();

            // Assert
            Assert.AreEqual(3, children.Length);

            var overtoppingOutputContext = children[0] as OvertoppingOutputContext;

            Assert.IsNotNull(overtoppingOutputContext);
            Assert.AreSame(grassCoverErosionInwardsCalculation, overtoppingOutputContext.WrappedData);

            var dikeHeightOutputContext = children[1] as DikeHeightOutputContext;

            Assert.IsNotNull(dikeHeightOutputContext);
            Assert.AreSame(grassCoverErosionInwardsCalculation, dikeHeightOutputContext.WrappedData);

            var overtoppingRateOutputContext = children[2] as OvertoppingRateOutputContext;

            Assert.IsNotNull(overtoppingRateOutputContext);
            Assert.AreSame(grassCoverErosionInwardsCalculation, overtoppingRateOutputContext.WrappedData);
        }
        public void ChildNodeObjects_WithData_ReturnsChildrenWithContextAndDataReversed()
        {
            // Setup
            var chartData1          = new TestChartData();
            var chartData2          = new TestChartData();
            var chartData3          = new TestChartData();
            var chartDataCollection = new ChartDataCollection("test data");

            chartDataCollection.Add(chartData1);
            chartDataCollection.Add(chartData2);
            chartDataCollection.Add(chartData3);

            // Call
            object[] objects = info.ChildNodeObjects(chartDataCollection);

            // Assert
            var expectedChildren = new[]
            {
                new ChartDataContext(chartData3, chartDataCollection),
                new ChartDataContext(chartData2, chartDataCollection),
                new ChartDataContext(chartData1, chartDataCollection)
            };

            CollectionAssert.AreEqual(expectedChildren, objects);
        }
Пример #13
0
        public void ChildNodeObjects_Always_ReturnHeightStructures()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new HeightStructuresFailureMechanism();

            failureMechanism.HeightStructures.AddRange(new[]
            {
                new TestHeightStructure("first id", "TestHeightStructure 1"),
                new TestHeightStructure("second id", "TestHeightStructure 2")
            }, "some path");

            var heightStructuresContext = new HeightStructuresContext(failureMechanism.HeightStructures,
                                                                      failureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(heightStructuresContext);

            // Assert
            CollectionAssert.AreEqual(failureMechanism.HeightStructures, children);
            mocks.VerifyAll();
        }
Пример #14
0
        public void ChildNodeObjects_NoDuneLocationsPresent_ReturnsExpectedChildData()
        {
            // Setup
            var duneLocationCalculationsForTargetProbability1 = new DuneLocationCalculationsForTargetProbability(0.1);
            var duneLocationCalculationsForTargetProbability2 = new DuneLocationCalculationsForTargetProbability(0.01);

            var calculationsForTargetProbabilities = new ObservableList <DuneLocationCalculationsForTargetProbability>
            {
                duneLocationCalculationsForTargetProbability1,
                duneLocationCalculationsForTargetProbability2
            };

            var calculationsGroupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(calculationsForTargetProbabilities,
                                                                                                                     new DuneErosionFailureMechanism(),
                                                                                                                     new AssessmentSectionStub());

            using (var plugin = new DuneErosionPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] childNodeObjects = info.ChildNodeObjects(calculationsGroupContext);

                // Assert
                CollectionAssert.IsEmpty(childNodeObjects);
            }
        }
Пример #15
0
        public void ChildNodeObjects_WithContext_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection        = new AssessmentSection(AssessmentSectionComposition.Dike);
            var assessmentSectionContext = new AssessmentSectionStateRootContext(assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);
                // Call
                object[] objects = info.ChildNodeObjects(assessmentSectionContext).ToArray();

                // Assert
                Assert.AreEqual(4, objects.Length);

                var referenceLineContext = (ReferenceLineContext)objects[0];
                Assert.AreSame(assessmentSection.ReferenceLine, referenceLineContext.WrappedData);
                Assert.AreSame(assessmentSection, referenceLineContext.AssessmentSection);

                var normContext = (NormContext)objects[1];
                Assert.AreSame(assessmentSection.FailureMechanismContribution, normContext.WrappedData);
                Assert.AreSame(assessmentSection, normContext.AssessmentSection);

                var backgroundData = (BackgroundData)objects[2];
                Assert.AreSame(assessmentSection.BackgroundData, backgroundData);

                var comment = (Comment)objects[3];
                Assert.AreSame(assessmentSection.Comments, comment);
            }
        }
Пример #16
0
        public void ChildNodeObjects_WithContext_ReturnChildDataNodes()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new GrassCoverErosionOutwardsFailureMechanism();
            var context           = new GrassCoverErosionOutwardsFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(context).ToArray();

            // Assert
            Assert.AreEqual(2, children.Length);
            var inputsFolder = (CategoryTreeFolder)children[0];

            Assert.AreEqual("Invoer", inputsFolder.Name);
            Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category);

            Assert.AreEqual(2, inputsFolder.Contents.Count());
            var foreshoreProfilesContext = (ForeshoreProfilesContext)inputsFolder.Contents.ElementAt(0);

            Assert.AreSame(failureMechanism.ForeshoreProfiles, foreshoreProfilesContext.WrappedData);
            Assert.AreSame(failureMechanism, foreshoreProfilesContext.ParentFailureMechanism);
            Assert.AreSame(assessmentSection, foreshoreProfilesContext.ParentAssessmentSection);

            var calculationsInputComments = (Comment)inputsFolder.Contents.ElementAt(1);

            Assert.AreSame(failureMechanism.CalculationsInputComments, calculationsInputComments);

            var calculationGroupContext = (GrassCoverErosionOutwardsCalculationGroupContext)children[1];

            Assert.AreSame(failureMechanism.CalculationsGroup, calculationGroupContext.WrappedData);
            Assert.IsNull(calculationGroupContext.Parent);
            Assert.AreSame(failureMechanism, calculationGroupContext.FailureMechanism);
            Assert.AreSame(assessmentSection, calculationGroupContext.AssessmentSection);
        }
        public void ChildNodeObjects_Always_ReturnDikeProfiles()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            DikeProfile dikeProfile1     = DikeProfileTestFactory.CreateDikeProfile(string.Empty, "id1");
            DikeProfile dikeProfile2     = DikeProfileTestFactory.CreateDikeProfile(string.Empty, "id2");
            var         failureMechanism = new GrassCoverErosionInwardsFailureMechanism();

            failureMechanism.DikeProfiles.AddRange(new[]
            {
                dikeProfile1,
                dikeProfile2
            }, "path");

            var dikeProfilesContext = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(dikeProfilesContext);

            // Assert
            Assert.AreEqual(2, children.Length);
            Assert.AreSame(dikeProfile1, children.ElementAt(0));
            Assert.AreSame(dikeProfile2, children.ElementAt(1));
            mocks.VerifyAll();
        }
        public void ChildNodeObjects_WithContext_ReturnsChildrenOfData()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());
            var context           = new AssemblyResultsContext(assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] objects = info.ChildNodeObjects(context).ToArray();

                // Assert
                Assert.AreEqual(4, objects.Length);

                var assessmentSectionAssemblyGroupsContext = (AssessmentSectionAssemblyGroupsContext)objects[0];
                Assert.AreSame(assessmentSection, assessmentSectionAssemblyGroupsContext.WrappedData);

                var assemblyResultTotalContext = (AssemblyResultTotalContext)objects[1];
                Assert.AreSame(assessmentSection, assemblyResultTotalContext.WrappedData);

                var assemblyResultPerSectionContext = (AssemblyResultPerSectionContext)objects[2];
                Assert.AreSame(assessmentSection, assemblyResultPerSectionContext.WrappedData);

                var assemblyResultPerSectionMapContext = (AssemblyResultPerSectionMapContext)objects[3];
                Assert.AreSame(assessmentSection, assemblyResultPerSectionMapContext.WrappedData);
            }
        }
Пример #19
0
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("Name", new[]
            {
                new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()),
                new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile())
            });

            var failureMechanism = new PipingFailureMechanism();
            var stochasticSoilModelCollectionContext = new PipingStochasticSoilModelCollectionContext(
                failureMechanism.StochasticSoilModels,
                failureMechanism,
                assessmentSection);

            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                stochasticSoilModel
            }, "path");

            // Call
            object[] objects = info.ChildNodeObjects(stochasticSoilModelCollectionContext);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                stochasticSoilModel
            }, objects);
        }
Пример #20
0
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();

            var calculationsForTargetProbabilities = new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>
            {
                new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1),
                new HydraulicBoundaryLocationCalculationsForTargetProbability(0.01)
            };
            var calculationsGroupContext = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(calculationsForTargetProbabilities, assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] childNodeObjects = info.ChildNodeObjects(calculationsGroupContext);

                // Assert
                Assert.AreEqual(2, childNodeObjects.Length);

                WaveHeightCalculationsForUserDefinedTargetProbabilityContext[] calculationsContexts = childNodeObjects.OfType <WaveHeightCalculationsForUserDefinedTargetProbabilityContext>().ToArray();
                Assert.AreEqual(2, calculationsContexts.Length);

                Assert.AreSame(calculationsForTargetProbabilities[0], calculationsContexts[0].WrappedData);
                Assert.AreSame(assessmentSection, calculationsContexts[0].AssessmentSection);

                Assert.AreSame(calculationsForTargetProbabilities[1], calculationsContexts[1].WrappedData);
                Assert.AreSame(assessmentSection, calculationsContexts[1].AssessmentSection);
            }
        }
        public void ChildNodeObjects_WithContext_ReturnChildDataNodes()
        {
            // Setup
            var assessmentSection      = new AssessmentSectionStub();
            var pipingFailureMechanism = new PipingFailureMechanism();
            var context = new PipingFailureMechanismContext(pipingFailureMechanism, assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(context).ToArray();

            // Assert
            Assert.AreEqual(2, children.Length);
            var inputsFolder = (CategoryTreeFolder)children[0];

            Assert.AreEqual("Invoer", inputsFolder.Name);
            Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category);

            Assert.AreEqual(4, inputsFolder.Contents.Count());
            var failureMechanismSectionsContext = (FailureMechanismSectionsContext)inputsFolder.Contents.ElementAt(0);

            Assert.AreSame(pipingFailureMechanism, failureMechanismSectionsContext.WrappedData);
            Assert.AreSame(assessmentSection, failureMechanismSectionsContext.AssessmentSection);

            var surfaceLinesContext = (PipingSurfaceLinesContext)inputsFolder.Contents.ElementAt(1);

            Assert.AreSame(pipingFailureMechanism.SurfaceLines, surfaceLinesContext.WrappedData);
            Assert.AreSame(pipingFailureMechanism, surfaceLinesContext.FailureMechanism);
            Assert.AreSame(assessmentSection, surfaceLinesContext.AssessmentSection);

            var stochasticSoilModelContext = (PipingStochasticSoilModelCollectionContext)inputsFolder.Contents.ElementAt(2);

            Assert.AreSame(pipingFailureMechanism, stochasticSoilModelContext.FailureMechanism);
            Assert.AreSame(pipingFailureMechanism, stochasticSoilModelContext.FailureMechanism);
            Assert.AreSame(assessmentSection, stochasticSoilModelContext.AssessmentSection);

            var calculationsInputComments = (Comment)inputsFolder.Contents.ElementAt(3);

            Assert.AreSame(pipingFailureMechanism.CalculationsInputComments, calculationsInputComments);

            var calculationsFolder = (PipingCalculationGroupContext)children[1];

            Assert.AreSame(pipingFailureMechanism.CalculationsGroup, calculationsFolder.WrappedData);
            Assert.IsNull(calculationsFolder.Parent);
            Assert.AreSame(pipingFailureMechanism.SurfaceLines, calculationsFolder.AvailablePipingSurfaceLines);
            Assert.AreSame(pipingFailureMechanism.StochasticSoilModels, calculationsFolder.AvailableStochasticSoilModels);
            Assert.AreSame(pipingFailureMechanism, calculationsFolder.FailureMechanism);
        }
Пример #22
0
        public void ChildNodeObjects_DuneLocationsPresent_ReturnsExpectedChildData()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new DuneErosionFailureMechanism();

            failureMechanism.SetDuneLocations(new[]
            {
                new TestDuneLocation()
            });

            var duneLocationCalculationsForTargetProbability1 = new DuneLocationCalculationsForTargetProbability(0.1);
            var duneLocationCalculationsForTargetProbability2 = new DuneLocationCalculationsForTargetProbability(0.01);

            var calculationsForTargetProbabilities = new ObservableList <DuneLocationCalculationsForTargetProbability>
            {
                duneLocationCalculationsForTargetProbability1,
                duneLocationCalculationsForTargetProbability2
            };

            var calculationsGroupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                calculationsForTargetProbabilities, failureMechanism, assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] childNodeObjects = info.ChildNodeObjects(calculationsGroupContext);

                // Assert
                Assert.AreEqual(2, childNodeObjects.Length);

                DuneLocationCalculationsForUserDefinedTargetProbabilityContext[] calculationsContexts = childNodeObjects.OfType <DuneLocationCalculationsForUserDefinedTargetProbabilityContext>().ToArray();
                Assert.AreEqual(2, calculationsContexts.Length);

                Assert.AreSame(duneLocationCalculationsForTargetProbability1, calculationsContexts[0].WrappedData);
                Assert.AreSame(failureMechanism, calculationsContexts[0].FailureMechanism);
                Assert.AreSame(assessmentSection, calculationsContexts[0].AssessmentSection);

                Assert.AreSame(duneLocationCalculationsForTargetProbability2, calculationsContexts[1].WrappedData);
                Assert.AreSame(failureMechanism, calculationsContexts[1].FailureMechanism);
                Assert.AreSame(assessmentSection, calculationsContexts[1].AssessmentSection);
            }
        }
Пример #23
0
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var soilProfile1 = new MacroStabilityInwardsSoilProfile1D("soilProfile1", 0, new List <MacroStabilityInwardsSoilLayer1D>
            {
                new MacroStabilityInwardsSoilLayer1D(10)
            });
            var soilProfile2 = new MacroStabilityInwardsSoilProfile1D("soilProfile2", 0, new List <MacroStabilityInwardsSoilLayer1D>
            {
                new MacroStabilityInwardsSoilLayer1D(10)
            });
            var stochasticSoilProfile1 = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile1);
            var stochasticSoilProfile2 = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile2);

            MacroStabilityInwardsStochasticSoilModel stochasticSoilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel(new[]
            {
                stochasticSoilProfile1,
                stochasticSoilProfile2
            });

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            var stochasticSoilModelCollectionContext = new MacroStabilityInwardsStochasticSoilModelCollectionContext(
                failureMechanism.StochasticSoilModels,
                failureMechanism,
                assessmentSection);

            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                stochasticSoilModel
            }, "path");

            // Call
            object[] objects = info.ChildNodeObjects(stochasticSoilModelCollectionContext);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                stochasticSoilModel
            }, objects);
        }
Пример #24
0
        public void ChildNodeObjects_HydraulicBoundaryDatabaseNotLinked_ReturnsEmpty()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
            var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase,
                                                                                        assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] objects = info.ChildNodeObjects(hydraulicBoundaryDatabaseContext).ToArray();

                // Assert
                Assert.AreEqual(0, objects.Length);
            }
        }
        public void ChildNodeObjects_Always_ReturnOutputChildNode()
        {
            // Setup
            var calculation = new MacroStabilityInwardsCalculationScenario();

            var failureMechanism  = new MacroStabilityInwardsFailureMechanism();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculationContext = new MacroStabilityInwardsCalculationScenarioContext(calculation,
                                                                                         new CalculationGroup(),
                                                                                         new[]
            {
                new MacroStabilityInwardsSurfaceLine(string.Empty)
            },
                                                                                         new[]
            {
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel()
            },
                                                                                         failureMechanism,
                                                                                         assessmentSection);

            // Call
            object[] children = info.ChildNodeObjects(calculationContext).ToArray();

            // Assert
            Assert.AreEqual(3, children.Length);
            var comment = (Comment)children[0];

            Assert.AreSame(calculationContext.WrappedData.Comments, comment);

            var inputContext = (MacroStabilityInwardsInputContext)children[1];

            Assert.AreSame(calculationContext.WrappedData.InputParameters, inputContext.WrappedData);
            CollectionAssert.AreEqual(calculationContext.AvailableMacroStabilityInwardsSurfaceLines, inputContext.AvailableMacroStabilityInwardsSurfaceLines);
            CollectionAssert.AreEqual(calculationContext.AvailableStochasticSoilModels, inputContext.AvailableStochasticSoilModels);

            var outputContext = (MacroStabilityInwardsOutputContext)children[2];

            Assert.AreSame(calculationContext.WrappedData, outputContext.WrappedData);
            Assert.AreSame(calculationContext.FailureMechanism, outputContext.FailureMechanism);
            Assert.AreSame(calculationContext.AssessmentSection, outputContext.AssessmentSection);
        }
        public void ChildNodeObjects_FailureMechanismInAssemblyTrue_ReturnChildDataNodes()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new DuneErosionFailureMechanism();
            var context           = new DuneErosionFailureMechanismContext(failureMechanism, assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] children = info.ChildNodeObjects(context).ToArray();

                // Assert
                Assert.AreEqual(2, children.Length);
                var inputsFolder = (CategoryTreeFolder)children[0];
                Assert.AreEqual("Invoer", inputsFolder.Name);
                Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category);

                Assert.AreEqual(2, inputsFolder.Contents.Count());
                var failureMechanismSectionsContext = (FailureMechanismSectionsContext)inputsFolder.Contents.ElementAt(0);
                Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData);
                Assert.AreSame(assessmentSection, failureMechanismSectionsContext.AssessmentSection);

                var inAssemblyInputComments = (Comment)inputsFolder.Contents.ElementAt(1);
                Assert.AreSame(failureMechanism.InAssemblyInputComments, inAssemblyInputComments);

                var outputsFolder = (CategoryTreeFolder)children[1];
                Assert.AreEqual("Oordeel", outputsFolder.Name);
                Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category);

                Assert.AreEqual(2, outputsFolder.Contents.Count());

                var failureMechanismResultsContext = (DuneErosionFailureMechanismSectionResultContext)outputsFolder.Contents.ElementAt(0);
                Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism);
                Assert.AreSame(assessmentSection, failureMechanismResultsContext.AssessmentSection);
                Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData);

                var inAssemblyOutputComments = (Comment)outputsFolder.Contents.ElementAt(1);
                Assert.AreSame(failureMechanism.InAssemblyOutputComments, inAssemblyOutputComments);
            }
        }
Пример #27
0
        public void ChildNodeObjects_WithContext_ReturnChildDataNodes()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new StabilityPointStructuresFailureMechanism();
            var context           = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);

            using (var plugin = new StabilityPointStructuresPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                object[] children = info.ChildNodeObjects(context).ToArray();

                // Assert
                Assert.AreEqual(2, children.Length);

                var inputsFolder = (CategoryTreeFolder)children[0];
                Assert.AreEqual("Invoer", inputsFolder.Name);
                Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category);

                Assert.AreEqual(3, inputsFolder.Contents.Count());
                var profilesContext = (ForeshoreProfilesContext)inputsFolder.Contents.ElementAt(0);
                Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData);
                Assert.AreSame(failureMechanism, profilesContext.ParentFailureMechanism);
                Assert.AreSame(assessmentSection, profilesContext.ParentAssessmentSection);

                var stabilityPointStructuresContext = (StabilityPointStructuresContext)inputsFolder.Contents.ElementAt(1);
                Assert.AreSame(failureMechanism.StabilityPointStructures, stabilityPointStructuresContext.WrappedData);
                Assert.AreSame(failureMechanism, stabilityPointStructuresContext.FailureMechanism);
                Assert.AreSame(assessmentSection, stabilityPointStructuresContext.AssessmentSection);

                var calculationsInputComments = (Comment)inputsFolder.Contents.ElementAt(2);
                Assert.AreSame(failureMechanism.CalculationsInputComments, calculationsInputComments);

                var calculationsFolder = (StabilityPointStructuresCalculationGroupContext)children[1];
                Assert.AreSame(failureMechanism.CalculationsGroup, calculationsFolder.WrappedData);
                Assert.IsNull(calculationsFolder.Parent);
                Assert.AreSame(failureMechanism, calculationsFolder.FailureMechanism);
            }

            mocksRepository.VerifyAll();
        }
Пример #28
0
        public void ChildNodeObjects_WithContext_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
            var context           = new CalculationsStateRootContext(assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);
                // Call
                object[] objects = info.ChildNodeObjects(context).ToArray();

                // Assert
                Assert.AreEqual(6, objects.Length);

                var pipingFailureMechanismContext = (PipingFailureMechanismContext)objects[0];
                Assert.AreSame(assessmentSection.Piping, pipingFailureMechanismContext.WrappedData);
                Assert.AreSame(assessmentSection, pipingFailureMechanismContext.Parent);

                var grassCoverErosionInwardsFailureMechanismContext = (GrassCoverErosionInwardsFailureMechanismContext)objects[1];
                Assert.AreSame(assessmentSection.GrassCoverErosionInwards, grassCoverErosionInwardsFailureMechanismContext.WrappedData);
                Assert.AreSame(assessmentSection, grassCoverErosionInwardsFailureMechanismContext.Parent);

                var macroStabilityInwardsFailureMechanismContext = (MacroStabilityInwardsFailureMechanismContext)objects[2];
                Assert.AreSame(assessmentSection.MacroStabilityInwards, macroStabilityInwardsFailureMechanismContext.WrappedData);
                Assert.AreSame(assessmentSection, macroStabilityInwardsFailureMechanismContext.Parent);

                var heightStructuresFailureMechanismContext = (HeightStructuresFailureMechanismContext)objects[3];
                Assert.AreSame(assessmentSection.HeightStructures, heightStructuresFailureMechanismContext.WrappedData);
                Assert.AreSame(assessmentSection, heightStructuresFailureMechanismContext.Parent);

                var closingStructuresFailureMechanismContext = (ClosingStructuresFailureMechanismContext)objects[4];
                Assert.AreSame(assessmentSection.ClosingStructures, closingStructuresFailureMechanismContext.WrappedData);
                Assert.AreSame(assessmentSection, closingStructuresFailureMechanismContext.Parent);

                var stabilityPointStructuresFailureMechanismsContext = (StabilityPointStructuresFailureMechanismContext)objects[5];
                Assert.AreSame(assessmentSection.StabilityPointStructures, stabilityPointStructuresFailureMechanismsContext.WrappedData);
                Assert.AreSame(assessmentSection, stabilityPointStructuresFailureMechanismsContext.Parent);
            }
        }
Пример #29
0
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var stochasticSoilProfile1 = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile());
            var stochasticSoilProfile2 = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile());

            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("Name", new[]
            {
                stochasticSoilProfile1,
                stochasticSoilProfile2
            });

            // Call
            object[] objects = info.ChildNodeObjects(stochasticSoilModel);

            // Assert
            PipingStochasticSoilProfile[] expectedChildren =
            {
                stochasticSoilProfile1,
                stochasticSoilProfile2
            };
            CollectionAssert.AreEqual(expectedChildren, objects);
        }
        public void ChildNodeObjects_Always_ReturnsCollectionWithOutputObjects(bool hasOutput)
        {
            // Setup
            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Output = hasOutput ? PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints() : null
            };
            var context = new ProbabilisticPipingOutputContext(calculation);

            // Call
            object[] children = info.ChildNodeObjects(context).ToArray();

            // Assert
            Assert.AreEqual(2, children.Length);

            var profileSpecificOutputContext = children[0] as ProbabilisticPipingProfileSpecificOutputContext;

            Assert.AreSame(calculation, profileSpecificOutputContext.WrappedData);

            var sectionSpecificOutputContext = children[1] as ProbabilisticPipingSectionSpecificOutputContext;

            Assert.AreSame(calculation, sectionSpecificOutputContext.WrappedData);
        }