Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/OpenChartViewCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/OpenMapViewCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/OpenPointedTreeGraphViewCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/OpenStackChartViewCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/OpenThematicalMapViewCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Demo.Riskeer.Test.csproj'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/GUIs/DemoProjectPluginTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Properties/AssemblyInfo.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Ribbons/RingtoetsDemoProjectRibbonTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Views/ChartDataViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Views/MapDataViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Views/PointedTreeGraphViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/Views/StackChartDataViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d refers to a dead (removed) revision in file `Demo/Ringtoets/test/Demo.Ringtoets.Test/packages.config'. Fisheye: No comparison available. Pass `N' to diff? Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,678 @@ +// Copyright (C) Stichting Deltares 2018. 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.Collections.Generic; +using System.IO; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.Controls.Commands; +using Core.Common.Gui; +using Core.Common.Gui.Commands; +using Demo.Riskeer.Commands; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.ClosingStructures.Data; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.HeightStructures.Data; +using Ringtoets.Integration.Data; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.SoilProfile; +using Ringtoets.Piping.Primitives; +using Ringtoets.Piping.Service; +using Ringtoets.Revetment.Data; +using Ringtoets.StabilityPointStructures.Data; +using Ringtoets.StabilityStoneCover.Data; +using Ringtoets.WaveImpactAsphaltCover.Data; + +namespace Demo.Riskeer.Test.Commands +{ + [TestFixture] + public class AddNewDemoAssessmentSectionCommandTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var projectOwner = mocks.Stub(); + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var command = new AddNewDemoAssessmentSectionCommand(projectOwner, viewCommands); + + // Assert + Assert.IsInstanceOf(command); + Assert.IsFalse(command.Checked); + mocks.VerifyAll(); + } + + [Test] + public void Execute_GuiIsProperlyInitialized_AddNewAssessmentSectionWithDemoDataToRootProject() + { + // Setup + var project = new RingtoetsProject(); + + var mocks = new MockRepository(); + var projectOwner = mocks.Stub(); + projectOwner.Stub(po => po.Project).Return(project); + + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + var command = new AddNewDemoAssessmentSectionCommand(projectOwner, viewCommands); + project.Attach(observer); + + // Call + command.Execute(); + + // Assert + Assert.AreEqual(1, project.AssessmentSections.Count); + AssessmentSection demoAssessmentSection = project.AssessmentSections[0]; + Assert.AreEqual("Demo traject", demoAssessmentSection.Name); + Assert.AreEqual("6-3", demoAssessmentSection.Id); + + AssertHydraulicBoundaryDatabase(demoAssessmentSection); + + Assert.AreEqual(2380, demoAssessmentSection.ReferenceLine.Points.Count()); + + foreach (IFailureMechanism failureMechanism in demoAssessmentSection.GetFailureMechanisms()) + { + Assert.AreEqual(283, failureMechanism.Sections.Count()); + Assert.IsTrue(failureMechanism.FailureMechanismSectionSourcePath.Contains("traject_6-3_vakken.shp")); + } + + AssertGrassCoverErosionInwardsFailureMechanism(demoAssessmentSection); + AssertGrassCoverErosionOutwardsFailureMechanism(demoAssessmentSection); + AssertHeightStructuresFailureMechanism(demoAssessmentSection); + AssertClosingStructuresFailureMechanism(demoAssessmentSection); + AssertPipingFailureMechanism(demoAssessmentSection); + AssertStabilityPointStructuresFailureMechanism(demoAssessmentSection); + AssertStabilityStoneCoverFailureMechanism(demoAssessmentSection); + AssertWaveImpactAsphaltCoverFailureMechanism(demoAssessmentSection); + mocks.VerifyAll(); + } + + #region General + + private static void AssertCalculationConvergence(IEnumerable calculations) + { + Assert.IsTrue(calculations.All(c => c.Output.CalculationConvergence == CalculationConvergence.CalculatedConverged)); + } + + #region WaveConditions + + private static void AssertFailureMechanismCategoryWaveConditionsInput(FailureMechanismCategoryWaveConditionsInput inputParameters) + { + Assert.AreEqual(1300001, inputParameters.HydraulicBoundaryLocation.Id); + Assert.AreEqual(FailureMechanismCategoryType.MechanismSpecificLowerLimitNorm, inputParameters.CategoryType); + } + + private static void AssertAssessmentSectionCategoryWaveConditionsInput(AssessmentSectionCategoryWaveConditionsInput inputParameters) + { + Assert.AreEqual(1300001, inputParameters.HydraulicBoundaryLocation.Id); + Assert.AreEqual(AssessmentSectionCategoryType.LowerLimitNorm, inputParameters.CategoryType); + } + + #endregion + + #endregion + + #region FailureMechanisms + + #region GrassCoverErosionInwardsFailureMechanism + + private static void AssertGrassCoverErosionInwardsFailureMechanism(AssessmentSection demoAssessmentSection) + { + Assert.AreEqual(1, demoAssessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Count); + GrassCoverErosionInwardsCalculation calculation = demoAssessmentSection.GrassCoverErosionInwards + .CalculationsGroup.GetCalculations() + .OfType() + .First(); + AssertExpectedGrassCoverErosionInwardsInput(calculation.InputParameters); + } + + private static void AssertExpectedGrassCoverErosionInwardsInput(GrassCoverErosionInwardsInput inputParameters) + { + Assert.AreEqual(1300001, inputParameters.HydraulicBoundaryLocation.Id); + } + + #endregion + + #region GrassCoverErosionOutwardsFailureMechanism + + private static void AssertGrassCoverErosionOutwardsFailureMechanism(AssessmentSection demoAssessmentSection) + { + ObservableList hydraulicBoundaryLocations = demoAssessmentSection.HydraulicBoundaryDatabase.Locations; + GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwardsFailureMechanism = demoAssessmentSection.GrassCoverErosionOutwards; + + AssertHydraulicBoundaryLocationCalculations(grassCoverErosionOutwardsFailureMechanism, hydraulicBoundaryLocations); + AssertDesignWaterLevelsForGrassCoverErosionOutwards(grassCoverErosionOutwardsFailureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm); + AssertCalculationConvergence(grassCoverErosionOutwardsFailureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm); + AssertWaveHeightsForGrassCoverErosionOutwards(grassCoverErosionOutwardsFailureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm); + AssertCalculationConvergence(grassCoverErosionOutwardsFailureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm); + + Assert.AreEqual(1, demoAssessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Count); + GrassCoverErosionOutwardsWaveConditionsCalculation calculation = grassCoverErosionOutwardsFailureMechanism.WaveConditionsCalculationGroup.GetCalculations() + .OfType() + .First(); + AssertFailureMechanismCategoryWaveConditionsInput(calculation.InputParameters); + } + + private static void AssertHydraulicBoundaryLocationCalculations(GrassCoverErosionOutwardsFailureMechanism failureMechanism, IList hydraulicBoundaryLocations) + { + CollectionAssert.AreEqual(hydraulicBoundaryLocations, failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, failureMechanism.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, failureMechanism.WaveHeightCalculationsForMechanismSpecificSignalingNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, failureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + } + + private static void AssertDesignWaterLevelsForGrassCoverErosionOutwards(IObservableEnumerable calculations) + { + AssertHydraulicBoundaryCalculationResult(7.19, calculations, 0); + AssertHydraulicBoundaryCalculationResult(7.19, calculations, 1); + AssertHydraulicBoundaryCalculationResult(7.18, calculations, 2); + AssertHydraulicBoundaryCalculationResult(7.18, calculations, 3); + AssertHydraulicBoundaryCalculationResult(7.18, calculations, 4); + AssertHydraulicBoundaryCalculationResult(7.39, calculations, 5); + AssertHydraulicBoundaryCalculationResult(7.39, calculations, 6); + AssertHydraulicBoundaryCalculationResult(7.39, calculations, 7); + AssertHydraulicBoundaryCalculationResult(7.40, calculations, 8); + AssertHydraulicBoundaryCalculationResult(7.40, calculations, 9); + AssertHydraulicBoundaryCalculationResult(7.40, calculations, 10); + AssertHydraulicBoundaryCalculationResult(7.40, calculations, 11); + AssertHydraulicBoundaryCalculationResult(7.40, calculations, 12); + AssertHydraulicBoundaryCalculationResult(7.41, calculations, 13); + AssertHydraulicBoundaryCalculationResult(7.41, calculations, 14); + AssertHydraulicBoundaryCalculationResult(6.91, calculations, 15); + AssertHydraulicBoundaryCalculationResult(7.53, calculations, 16); + AssertHydraulicBoundaryCalculationResult(7.80, calculations, 17); + } + + private static void AssertWaveHeightsForGrassCoverErosionOutwards(IObservableEnumerable calculations) + { + AssertHydraulicBoundaryCalculationResult(4.99, calculations, 0); + AssertHydraulicBoundaryCalculationResult(5.04, calculations, 1); + AssertHydraulicBoundaryCalculationResult(4.87, calculations, 2); + AssertHydraulicBoundaryCalculationResult(4.73, calculations, 3); + AssertHydraulicBoundaryCalculationResult(4.59, calculations, 4); + AssertHydraulicBoundaryCalculationResult(3.35, calculations, 5); + AssertHydraulicBoundaryCalculationResult(3.83, calculations, 6); + AssertHydraulicBoundaryCalculationResult(4.00, calculations, 7); + AssertHydraulicBoundaryCalculationResult(4.20, calculations, 8); + AssertHydraulicBoundaryCalculationResult(4.41, calculations, 9); + AssertHydraulicBoundaryCalculationResult(4.50, calculations, 10); + AssertHydraulicBoundaryCalculationResult(4.57, calculations, 11); + AssertHydraulicBoundaryCalculationResult(4.63, calculations, 12); + AssertHydraulicBoundaryCalculationResult(4.68, calculations, 13); + AssertHydraulicBoundaryCalculationResult(4.17, calculations, 14); + AssertHydraulicBoundaryCalculationResult(11.13, calculations, 15); + AssertHydraulicBoundaryCalculationResult(9.24, calculations, 16); + AssertHydraulicBoundaryCalculationResult(5.34, calculations, 17); + } + + #endregion + + #region HeightStructuresFailureMechanism + + private static void AssertHeightStructuresFailureMechanism(AssessmentSection demoAssessmentSection) + { + Assert.AreEqual(1, demoAssessmentSection.HeightStructures.HeightStructures.Count); + AssertExpectedHeightStructureValues(demoAssessmentSection.HeightStructures.HeightStructures[0]); + + Assert.AreEqual(1, demoAssessmentSection.HeightStructures.CalculationsGroup.Children.Count); + StructuresCalculation calculation = demoAssessmentSection.HeightStructures + .Calculations + .OfType>() + .First(); + AssertExpectedHeightStructuresInput(calculation.InputParameters); + } + + private static void AssertExpectedHeightStructureValues(HeightStructure heightStructure) + { + Assert.AreEqual("Kunstwerk 1", heightStructure.Name); + Assert.AreEqual("KUNST1", heightStructure.Id); + Assert.AreEqual(new Point2D(12345.56789, 9876.54321), heightStructure.Location); + Assert.AreEqual(10.0, heightStructure.StructureNormalOrientation.Value); + Assert.AreEqual(4.95, heightStructure.LevelCrestStructure.Mean.Value); + Assert.AreEqual(0.05, heightStructure.LevelCrestStructure.StandardDeviation.Value); + Assert.AreEqual(25.0, heightStructure.FlowWidthAtBottomProtection.Mean.Value); + Assert.AreEqual(0.05, heightStructure.FlowWidthAtBottomProtection.StandardDeviation.Value); + Assert.AreEqual(0.1, heightStructure.CriticalOvertoppingDischarge.Mean.Value); + Assert.AreEqual(0.15, heightStructure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value); + Assert.AreEqual(21.0, heightStructure.WidthFlowApertures.Mean.Value); + Assert.AreEqual(0.05, heightStructure.WidthFlowApertures.StandardDeviation.Value); + Assert.AreEqual(1.0, heightStructure.FailureProbabilityStructureWithErosion); + Assert.AreEqual(20000.0, heightStructure.StorageStructureArea.Mean.Value); + Assert.AreEqual(0.1, heightStructure.StorageStructureArea.CoefficientOfVariation.Value); + Assert.AreEqual(0.2, heightStructure.AllowedLevelIncreaseStorage.Mean.Value); + Assert.AreEqual(0.1, heightStructure.AllowedLevelIncreaseStorage.StandardDeviation.Value); + } + + private static void AssertExpectedHeightStructuresInput(HeightStructuresInput inputParameters) + { + Assert.AreEqual(1300001, inputParameters.HydraulicBoundaryLocation.Id); + AssertExpectedHeightStructureValues(inputParameters.Structure); + } + + #endregion + + #region ClosingStructuresFailureMechanism + + private static void AssertClosingStructuresFailureMechanism(AssessmentSection demoAssessmentSection) + { + Assert.AreEqual(1, demoAssessmentSection.ClosingStructures.ClosingStructures.Count); + AssertExpectedClosingStructureValues(demoAssessmentSection.ClosingStructures.ClosingStructures[0]); + + Assert.AreEqual(1, demoAssessmentSection.ClosingStructures.CalculationsGroup.Children.Count); + StructuresCalculation calculation = demoAssessmentSection.ClosingStructures + .Calculations + .OfType>() + .First(); + AssertExpectedClosingStructuresInput(calculation.InputParameters); + } + + private static void AssertExpectedClosingStructureValues(ClosingStructure closingStructure) + { + Assert.AreEqual("Kunstwerk 1", closingStructure.Name); + Assert.AreEqual("KUNST1", closingStructure.Id); + Assert.AreEqual(new Point2D(12345.56789, 9876.54321), closingStructure.Location); + Assert.AreEqual(20000.0, closingStructure.StorageStructureArea.Mean.Value); + Assert.AreEqual(0.1, closingStructure.StorageStructureArea.CoefficientOfVariation.Value); + Assert.AreEqual(0.2, closingStructure.AllowedLevelIncreaseStorage.Mean.Value); + Assert.AreEqual(0.1, closingStructure.AllowedLevelIncreaseStorage.StandardDeviation.Value); + Assert.AreEqual(10.0, closingStructure.StructureNormalOrientation.Value); + Assert.AreEqual(21.0, closingStructure.WidthFlowApertures.Mean.Value); + Assert.AreEqual(0.05, closingStructure.WidthFlowApertures.StandardDeviation.Value); + Assert.AreEqual(4.95, closingStructure.LevelCrestStructureNotClosing.Mean.Value); + Assert.AreEqual(0.05, closingStructure.LevelCrestStructureNotClosing.StandardDeviation.Value); + Assert.AreEqual(0.5, closingStructure.InsideWaterLevel.Mean.Value); + Assert.AreEqual(0.1, closingStructure.InsideWaterLevel.StandardDeviation.Value); + Assert.AreEqual(4.95, closingStructure.ThresholdHeightOpenWeir.Mean.Value); + Assert.AreEqual(0.1, closingStructure.ThresholdHeightOpenWeir.StandardDeviation.Value); + Assert.AreEqual(31.5, closingStructure.AreaFlowApertures.Mean.Value); + Assert.AreEqual(0.01, closingStructure.AreaFlowApertures.StandardDeviation.Value); + Assert.AreEqual(1.0, closingStructure.CriticalOvertoppingDischarge.Mean.Value); + Assert.AreEqual(0.15, closingStructure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value); + Assert.AreEqual(25.0, closingStructure.FlowWidthAtBottomProtection.Mean.Value); + Assert.AreEqual(0.05, closingStructure.FlowWidthAtBottomProtection.StandardDeviation.Value); + Assert.AreEqual(1.0, closingStructure.ProbabilityOpenStructureBeforeFlooding); + Assert.AreEqual(0.1, closingStructure.FailureProbabilityOpenStructure); + Assert.AreEqual(4, closingStructure.IdenticalApertures); + Assert.AreEqual(1.0, closingStructure.FailureProbabilityReparation); + Assert.AreEqual(ClosingStructureInflowModelType.VerticalWall, closingStructure.InflowModelType); + } + + private static void AssertExpectedClosingStructuresInput(ClosingStructuresInput inputParameters) + { + Assert.AreEqual(1300001, inputParameters.HydraulicBoundaryLocation.Id); + AssertExpectedClosingStructureValues(inputParameters.Structure); + } + + #endregion + + #region PipingFailureMechanism + + private static void AssertPipingFailureMechanism(AssessmentSection demoAssessmentSection) + { + PipingStochasticSoilModel[] soilModels = demoAssessmentSection.Piping.StochasticSoilModels.ToArray(); + Assert.AreEqual(4, soilModels.Length); + PipingSurfaceLine[] surfaceLines = demoAssessmentSection.Piping.SurfaceLines.ToArray(); + Assert.AreEqual(4, surfaceLines.Length); + AssertCharacteristicPointsOnSurfaceLines(surfaceLines); + + Assert.AreEqual(1, demoAssessmentSection.Piping.CalculationsGroup.Children.Count); + PipingCalculationScenario pipingCalculationScenario = demoAssessmentSection.Piping + .CalculationsGroup.GetCalculations() + .OfType() + .First(); + AssertCalculationAbleToCalculate(pipingCalculationScenario, demoAssessmentSection); + AssertCalculationInFailureMechanismSectionResult( + pipingCalculationScenario, + demoAssessmentSection.Piping.SectionResults.ToArray(), + demoAssessmentSection.Piping.Calculations.OfType()); + } + + private static void AssertCharacteristicPointsOnSurfaceLines(PipingSurfaceLine[] surfaceLines) + { + PipingSurfaceLine surfaceLine1 = surfaceLines.FirstOrDefault(s => s.Name == "PK001_0001"); + PipingSurfaceLine surfaceLine2 = surfaceLines.FirstOrDefault(s => s.Name == "PK001_0002"); + PipingSurfaceLine surfaceLine3 = surfaceLines.FirstOrDefault(s => s.Name == "PK001_0003"); + PipingSurfaceLine surfaceLine4 = surfaceLines.FirstOrDefault(s => s.Name == "PK001_0004"); + + Assert.IsNotNull(surfaceLine1); + Assert.IsNotNull(surfaceLine2); + Assert.IsNotNull(surfaceLine3); + Assert.IsNotNull(surfaceLine4); + + Assert.AreEqual(new Point3D(155883.762, 569864.416, 0.53), surfaceLine1.DitchPolderSide); + Assert.AreEqual(new Point3D(155882.067, 569866.157, -1.9), surfaceLine1.BottomDitchPolderSide); + Assert.AreEqual(new Point3D(155874.184, 569874.252, -1.9), surfaceLine1.BottomDitchDikeSide); + Assert.AreEqual(new Point3D(155872.224, 569876.265, 0.91), surfaceLine1.DitchDikeSide); + Assert.AreEqual(new Point3D(155864.173, 569884.532, 0.95), surfaceLine1.DikeToeAtPolder); + Assert.AreEqual(new Point3D(155797.109, 569953.4, -4), surfaceLine1.DikeToeAtRiver); + + Assert.IsNull(surfaceLine2.DitchPolderSide); + Assert.IsNull(surfaceLine2.BottomDitchPolderSide); + Assert.IsNull(surfaceLine2.BottomDitchDikeSide); + Assert.IsNull(surfaceLine2.DitchDikeSide); + Assert.AreEqual(new Point3D(155558.754, 569618.729, 1.45), surfaceLine2.DikeToeAtPolder); + Assert.AreEqual(new Point3D(155505.259, 569701.229, -4), surfaceLine2.DikeToeAtRiver); + + Assert.AreEqual(new Point3D(155063.763, 569276.113, -0.5), surfaceLine3.DitchPolderSide); + Assert.AreEqual(new Point3D(155063.272, 569276.926, -1.45), surfaceLine3.BottomDitchPolderSide); + Assert.AreEqual(new Point3D(155056.855, 569287.56, -1.45), surfaceLine3.BottomDitchDikeSide); + Assert.AreEqual(new Point3D(155056.297, 569288.485, -0.37), surfaceLine3.DitchDikeSide); + Assert.AreEqual(new Point3D(155047.587, 569302.917, 1.42), surfaceLine3.DikeToeAtPolder); + Assert.AreEqual(new Point3D(154999.006, 569383.419, -4), surfaceLine3.DikeToeAtRiver); + + Assert.IsNull(surfaceLine4.DitchPolderSide); + Assert.IsNull(surfaceLine4.BottomDitchPolderSide); + Assert.IsNull(surfaceLine4.BottomDitchDikeSide); + Assert.IsNull(surfaceLine4.DitchDikeSide); + Assert.AreEqual(new Point3D(154682.383, 568112.623, 1.55), surfaceLine4.DikeToeAtPolder); + Assert.AreEqual(new Point3D(154586.088, 568119.17, -4), surfaceLine4.DikeToeAtRiver); + } + + private static void AssertExpectedPipingInput(PipingInput inputParameters) + { + Console.WriteLine(@"{0} en {1}", Math.Exp(-0.5), Math.Sqrt((Math.Exp(1) - 1) * Math.Exp(1))); + Assert.AreEqual(1.0, inputParameters.UpliftModelFactor, 1e-3); + Assert.AreEqual(1.0, inputParameters.SellmeijerModelFactor, 1e-3); + + Assert.AreEqual(9.81, inputParameters.WaterVolumetricWeight, 1e-3); + Assert.AreEqual(0.3, inputParameters.SellmeijerReductionFactor, 1e-3); + Assert.AreEqual(16.19, inputParameters.SandParticlesVolumicWeight, 1e-3); + Assert.AreEqual(0.25, inputParameters.WhitesDragCoefficient, 1e-3); + Assert.AreEqual(1.33e-6, inputParameters.WaterKinematicViscosity, 1e-3); + Assert.AreEqual(9.81, inputParameters.Gravity, 1e-3); + Assert.AreEqual(0.000, inputParameters.MeanDiameter70, 1e-3); + Assert.AreEqual(37, inputParameters.BeddingAngle, 1e-3); + + Assert.AreEqual("PK001_0001", inputParameters.SurfaceLine.Name); + Assert.AreEqual("PK001_0001_Piping", inputParameters.StochasticSoilModel.Name); + Assert.AreEqual("W1-6_0_1D1", inputParameters.StochasticSoilProfile.SoilProfile.Name); + Assert.AreEqual(1300001, inputParameters.HydraulicBoundaryLocation.Id); + + Assert.AreEqual(0.875, PipingSemiProbabilisticDesignVariableFactory.GetDampingFactorExit(inputParameters).GetDesignValue(), + inputParameters.DampingFactorExit.GetAccuracy()); + Assert.AreEqual(2.836, PipingSemiProbabilisticDesignVariableFactory.GetPhreaticLevelExit(inputParameters).GetDesignValue(), + inputParameters.PhreaticLevelExit.GetAccuracy()); + + Assert.AreEqual(106.13, inputParameters.ExitPointL, 1e-2); + Assert.AreEqual(81.18, PipingSemiProbabilisticDesignVariableFactory.GetSeepageLength(inputParameters).GetDesignValue(), + inputParameters.DampingFactorExit.GetAccuracy()); + Assert.AreEqual(5.86, PipingSemiProbabilisticDesignVariableFactory.GetThicknessCoverageLayer(inputParameters).GetDesignValue(), + inputParameters.DampingFactorExit.GetAccuracy()); + Assert.AreEqual(20.13, PipingSemiProbabilisticDesignVariableFactory.GetThicknessAquiferLayer(inputParameters).GetDesignValue(), + inputParameters.DampingFactorExit.GetAccuracy()); + } + + private static void AssertCalculationAbleToCalculate(PipingCalculationScenario calculation, IAssessmentSection assessmentSection) + { + PipingInput inputParameters = calculation.InputParameters; + AssertExpectedPipingInput(inputParameters); + + RoundedDouble assessmentLevel = assessmentSection.GetNormativeAssessmentLevel(calculation.InputParameters.HydraulicBoundaryLocation); + + Assert.IsTrue(PipingCalculationService.Validate(calculation, assessmentLevel)); + + PipingCalculationService.Calculate(calculation, assessmentLevel); + Assert.IsTrue(calculation.HasOutput); + Assert.AreEqual(0.683, calculation.Output.HeaveFactorOfSafety, 1e-3); + Assert.AreEqual(-0.139, calculation.Output.HeaveZValue, 1e-3); + Assert.AreEqual(1.784, calculation.Output.UpliftFactorOfSafety, 1e-3); + Assert.AreEqual(2.019, calculation.Output.UpliftZValue, 1e-3); + Assert.AreEqual(1.199, calculation.Output.SellmeijerFactorOfSafety, 1e-3); + Assert.AreEqual(0.237, calculation.Output.SellmeijerZValue, 1e-3); + } + + private static void AssertCalculationInFailureMechanismSectionResult(PipingCalculationScenario calculation, PipingFailureMechanismSectionResult[] sectionResults, IEnumerable calculations) + { + Assert.AreEqual(283, sectionResults.Length); + PipingFailureMechanismSectionResult sectionResultWithCalculation = sectionResults[22]; + + CollectionAssert.AreEqual(new[] + { + calculation + }, sectionResultWithCalculation.GetCalculationScenarios(calculations)); + } + + #endregion + + #region StabilityPointStructuresFailureMechanism + + private static void AssertStabilityPointStructuresFailureMechanism(AssessmentSection demoAssessmentSection) + { + Assert.AreEqual(1, demoAssessmentSection.StabilityPointStructures.CalculationsGroup.Children.Count); + AssertExpectedStabilityPointStructureValues(demoAssessmentSection.StabilityPointStructures.StabilityPointStructures[0]); + StructuresCalculation calculation = demoAssessmentSection.StabilityPointStructures + .Calculations + .OfType>() + .First(); + AssertExpectedStabilityPointStructuresInput(calculation.InputParameters); + } + + private static void AssertExpectedStabilityPointStructureValues(StabilityPointStructure structure) + { + Assert.AreEqual("Kunstwerk", structure.Name); + Assert.AreEqual("Kunstwerk id", structure.Id); + Assert.AreEqual(new Point2D(131470.777221421, 548329.82912364), structure.Location); + Assert.AreEqual(10, structure.StructureNormalOrientation, structure.StructureNormalOrientation.GetAccuracy()); + Assert.AreEqual(20000, structure.StorageStructureArea.Mean, structure.StorageStructureArea.Mean.GetAccuracy()); + Assert.AreEqual(0.1, structure.StorageStructureArea.CoefficientOfVariation, + structure.StorageStructureArea.CoefficientOfVariation.GetAccuracy()); + Assert.AreEqual(0.2, structure.AllowedLevelIncreaseStorage.Mean, structure.AllowedLevelIncreaseStorage.Mean.GetAccuracy()); + Assert.AreEqual(0.1, structure.AllowedLevelIncreaseStorage.StandardDeviation, + structure.AllowedLevelIncreaseStorage.StandardDeviation.GetAccuracy()); + Assert.AreEqual(21, structure.WidthFlowApertures.Mean, structure.WidthFlowApertures.Mean.GetAccuracy()); + Assert.AreEqual(0.05, structure.WidthFlowApertures.StandardDeviation, structure.WidthFlowApertures.StandardDeviation.GetAccuracy()); + Assert.AreEqual(0.5, structure.InsideWaterLevel.Mean, structure.InsideWaterLevel.Mean.GetAccuracy()); + Assert.AreEqual(0.1, structure.InsideWaterLevel.StandardDeviation, structure.InsideWaterLevel.StandardDeviation.GetAccuracy()); + Assert.AreEqual(4.95, structure.ThresholdHeightOpenWeir.Mean, structure.ThresholdHeightOpenWeir.Mean.GetAccuracy()); + Assert.AreEqual(0.1, structure.ThresholdHeightOpenWeir.StandardDeviation, structure.ThresholdHeightOpenWeir.StandardDeviation.GetAccuracy()); + Assert.AreEqual(1, structure.CriticalOvertoppingDischarge.Mean, structure.CriticalOvertoppingDischarge.Mean.GetAccuracy()); + Assert.AreEqual(0.15, structure.CriticalOvertoppingDischarge.CoefficientOfVariation, + structure.CriticalOvertoppingDischarge.CoefficientOfVariation.GetAccuracy()); + Assert.AreEqual(25, structure.FlowWidthAtBottomProtection.Mean, structure.FlowWidthAtBottomProtection.Mean.GetAccuracy()); + Assert.AreEqual(1.25, structure.FlowWidthAtBottomProtection.StandardDeviation, + structure.FlowWidthAtBottomProtection.StandardDeviation.GetAccuracy()); + Assert.AreEqual(10, structure.ConstructiveStrengthLinearLoadModel.Mean, structure.ConstructiveStrengthLinearLoadModel.Mean.GetAccuracy()); + Assert.AreEqual(0.1, structure.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation, + structure.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation.GetAccuracy()); + Assert.AreEqual(10, structure.ConstructiveStrengthQuadraticLoadModel.Mean, + structure.ConstructiveStrengthQuadraticLoadModel.Mean.GetAccuracy()); + Assert.AreEqual(0.1, structure.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation, + structure.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation.GetAccuracy()); + Assert.AreEqual(0, structure.BankWidth.Mean, structure.BankWidth.Mean.GetAccuracy()); + Assert.AreEqual(0, structure.BankWidth.StandardDeviation, structure.BankWidth.StandardDeviation.GetAccuracy()); + Assert.AreEqual(0.5, structure.InsideWaterLevelFailureConstruction.Mean, structure.InsideWaterLevelFailureConstruction.Mean.GetAccuracy()); + Assert.AreEqual(0.1, structure.InsideWaterLevelFailureConstruction.StandardDeviation, + structure.InsideWaterLevelFailureConstruction.StandardDeviation.GetAccuracy()); + Assert.AreEqual(0, structure.EvaluationLevel, structure.EvaluationLevel.GetAccuracy()); + Assert.AreEqual(4.95, structure.LevelCrestStructure.Mean, structure.LevelCrestStructure.Mean.GetAccuracy()); + Assert.AreEqual(0.05, structure.LevelCrestStructure.StandardDeviation, structure.LevelCrestStructure.StandardDeviation.GetAccuracy()); + Assert.AreEqual(0, structure.VerticalDistance, structure.VerticalDistance.GetAccuracy()); + Assert.AreEqual(0.5, structure.FailureProbabilityRepairClosure); + Assert.AreEqual(10, structure.FailureCollisionEnergy.Mean, structure.FailureCollisionEnergy.Mean.GetAccuracy()); + Assert.AreEqual(0.3, structure.FailureCollisionEnergy.CoefficientOfVariation, + structure.FailureCollisionEnergy.CoefficientOfVariation.GetAccuracy()); + Assert.AreEqual(16000, structure.ShipMass.Mean, structure.ShipMass.Mean.GetAccuracy()); + Assert.AreEqual(0.2, structure.ShipMass.CoefficientOfVariation, structure.ShipMass.CoefficientOfVariation.GetAccuracy()); + Assert.AreEqual(2, structure.ShipVelocity.Mean, structure.ShipVelocity.Mean.GetAccuracy()); + Assert.AreEqual(0.2, structure.ShipVelocity.CoefficientOfVariation, structure.ShipVelocity.CoefficientOfVariation.GetAccuracy()); + Assert.AreEqual(0, structure.LevellingCount); + Assert.AreEqual(0, structure.ProbabilityCollisionSecondaryStructure); + Assert.AreEqual(1, structure.FlowVelocityStructureClosable.Mean, structure.FlowVelocityStructureClosable.Mean.GetAccuracy()); + Assert.AreEqual(15, structure.StabilityLinearLoadModel.Mean, structure.StabilityLinearLoadModel.Mean.GetAccuracy()); + Assert.AreEqual(0.1, structure.StabilityLinearLoadModel.CoefficientOfVariation, + structure.StabilityLinearLoadModel.CoefficientOfVariation.GetAccuracy()); + Assert.AreEqual(15, structure.StabilityQuadraticLoadModel.Mean, structure.StabilityQuadraticLoadModel.Mean.GetAccuracy()); + Assert.AreEqual(0.1, structure.StabilityQuadraticLoadModel.CoefficientOfVariation, + structure.StabilityQuadraticLoadModel.CoefficientOfVariation.GetAccuracy()); + Assert.AreEqual(2.5, structure.AreaFlowApertures.Mean, structure.AreaFlowApertures.Mean.GetAccuracy()); + Assert.AreEqual(0.01, structure.AreaFlowApertures.StandardDeviation, structure.AreaFlowApertures.StandardDeviation.GetAccuracy()); + Assert.AreEqual(StabilityPointStructureInflowModelType.FloodedCulvert, structure.InflowModelType); + } + + private static void AssertExpectedStabilityPointStructuresInput(StabilityPointStructuresInput inputParameters) + { + Assert.AreEqual(1300001, inputParameters.HydraulicBoundaryLocation.Id); + } + + #endregion + + #region StabilityStoneCoverFailureMechanism + + private static void AssertStabilityStoneCoverFailureMechanism(AssessmentSection demoAssessmentSection) + { + Assert.AreEqual(1, demoAssessmentSection.StabilityStoneCover.WaveConditionsCalculationGroup.Children.Count); + StabilityStoneCoverWaveConditionsCalculation calculation = demoAssessmentSection.StabilityStoneCover + .WaveConditionsCalculationGroup.GetCalculations() + .OfType() + .First(); + AssertAssessmentSectionCategoryWaveConditionsInput(calculation.InputParameters); + } + + #endregion + + #region WaveImpactAsphaltCoverFailureMechanism + + private static void AssertWaveImpactAsphaltCoverFailureMechanism(AssessmentSection demoAssessmentSection) + { + Assert.AreEqual(1, demoAssessmentSection.WaveImpactAsphaltCover.WaveConditionsCalculationGroup.Children.Count); + WaveImpactAsphaltCoverWaveConditionsCalculation calculation = demoAssessmentSection.WaveImpactAsphaltCover + .WaveConditionsCalculationGroup.GetCalculations() + .OfType() + .First(); + AssertAssessmentSectionCategoryWaveConditionsInput(calculation.InputParameters); + } + + #endregion + + #endregion + + #region HydraulicBoundaryDatabase + + private static void AssertHydraulicBoundaryDatabase(AssessmentSection demoAssessmentSection) + { + Assert.IsNotEmpty(demoAssessmentSection.HydraulicBoundaryDatabase.FilePath); + Assert.IsTrue(File.Exists(demoAssessmentSection.HydraulicBoundaryDatabase.FilePath)); + string directoryName = Path.GetDirectoryName(demoAssessmentSection.HydraulicBoundaryDatabase.FilePath); + Assert.IsNotNull(directoryName); + Assert.IsTrue(File.Exists(Path.Combine(directoryName, "HLCD.sqlite"))); + + ObservableList hydraulicBoundaryLocations = demoAssessmentSection.HydraulicBoundaryDatabase.Locations; + Assert.AreEqual(18, hydraulicBoundaryLocations.Count); + AssertHydraulicBoundaryLocationCalculations(demoAssessmentSection); + AssertDesignWaterLevelsForAssessmentSection(demoAssessmentSection); + AssertCalculationConvergence(demoAssessmentSection.WaterLevelCalculationsForLowerLimitNorm); + AssertWaveHeightsForAssessmentSection(demoAssessmentSection); + AssertCalculationConvergence(demoAssessmentSection.WaveHeightCalculationsForLowerLimitNorm); + } + + private static void AssertHydraulicBoundaryLocationCalculations(IAssessmentSection assessmentSection) + { + ObservableList hydraulicBoundaryLocations = assessmentSection.HydraulicBoundaryDatabase.Locations; + + CollectionAssert.AreEqual(hydraulicBoundaryLocations, assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, assessmentSection.WaterLevelCalculationsForSignalingNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, assessmentSection.WaterLevelCalculationsForLowerLimitNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, assessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, assessmentSection.WaveHeightCalculationsForSignalingNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, assessmentSection.WaveHeightCalculationsForLowerLimitNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + CollectionAssert.AreEqual(hydraulicBoundaryLocations, assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm.Select(hblc => hblc.HydraulicBoundaryLocation)); + } + + private static void AssertDesignWaterLevelsForAssessmentSection(IAssessmentSection assessmentSection) + { + IObservableEnumerable calculations = assessmentSection.WaterLevelCalculationsForLowerLimitNorm; + + AssertHydraulicBoundaryCalculationResult(5.78, calculations, 0); + AssertHydraulicBoundaryCalculationResult(5.77, calculations, 1); + AssertHydraulicBoundaryCalculationResult(5.77, calculations, 2); + AssertHydraulicBoundaryCalculationResult(5.77, calculations, 3); + AssertHydraulicBoundaryCalculationResult(5.77, calculations, 4); + AssertHydraulicBoundaryCalculationResult(5.93, calculations, 5); + AssertHydraulicBoundaryCalculationResult(5.93, calculations, 6); + AssertHydraulicBoundaryCalculationResult(5.93, calculations, 7); + AssertHydraulicBoundaryCalculationResult(5.93, calculations, 8); + AssertHydraulicBoundaryCalculationResult(5.93, calculations, 9); + AssertHydraulicBoundaryCalculationResult(5.93, calculations, 10); + AssertHydraulicBoundaryCalculationResult(5.93, calculations, 11); + AssertHydraulicBoundaryCalculationResult(5.93, calculations, 12); + AssertHydraulicBoundaryCalculationResult(5.93, calculations, 13); + AssertHydraulicBoundaryCalculationResult(5.93, calculations, 14); + AssertHydraulicBoundaryCalculationResult(5.54, calculations, 15); + AssertHydraulicBoundaryCalculationResult(5.86, calculations, 16); + AssertHydraulicBoundaryCalculationResult(6.00, calculations, 17); + } + + private static void AssertWaveHeightsForAssessmentSection(IAssessmentSection assessmentSection) + { + IObservableEnumerable calculations = assessmentSection.WaveHeightCalculationsForLowerLimitNorm; + + AssertHydraulicBoundaryCalculationResult(4.13, calculations, 0); + AssertHydraulicBoundaryCalculationResult(4.19, calculations, 1); + AssertHydraulicBoundaryCalculationResult(4.02, calculations, 2); + AssertHydraulicBoundaryCalculationResult(3.87, calculations, 3); + AssertHydraulicBoundaryCalculationResult(3.73, calculations, 4); + AssertHydraulicBoundaryCalculationResult(2.65, calculations, 5); + AssertHydraulicBoundaryCalculationResult(3.04, calculations, 6); + AssertHydraulicBoundaryCalculationResult(3.20, calculations, 7); + AssertHydraulicBoundaryCalculationResult(3.35, calculations, 8); + AssertHydraulicBoundaryCalculationResult(3.53, calculations, 9); + AssertHydraulicBoundaryCalculationResult(3.62, calculations, 10); + AssertHydraulicBoundaryCalculationResult(3.68, calculations, 11); + AssertHydraulicBoundaryCalculationResult(3.73, calculations, 12); + AssertHydraulicBoundaryCalculationResult(3.75, calculations, 13); + AssertHydraulicBoundaryCalculationResult(3.30, calculations, 14); + AssertHydraulicBoundaryCalculationResult(9.57, calculations, 15); + AssertHydraulicBoundaryCalculationResult(8.02, calculations, 16); + AssertHydraulicBoundaryCalculationResult(4.11, calculations, 17); + } + + private static void AssertHydraulicBoundaryCalculationResult(double expectedResult, IObservableEnumerable calculations, int index) + { + RoundedDouble result = calculations.ElementAt(index).Output.Result; + + Assert.AreEqual(expectedResult, result, result.GetAccuracy()); + } + + #endregion + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenChartViewCommandTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenChartViewCommandTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenChartViewCommandTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,68 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Gui.Commands; +using Demo.Riskeer.Commands; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Demo.Riskeer.Test.Commands +{ + [TestFixture] + public class OpenChartViewCommandTest + { + [Test] + public void Execute_Always_OpensViewForIChartData() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.StrictMock(); + viewCommands.Expect(g => g.OpenView(Arg.Is.NotNull)); + mocks.ReplayAll(); + + var command = new OpenChartViewCommand(viewCommands); + + // Call + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void Checked_Always_ReturnsFalse() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + var command = new OpenChartViewCommand(viewCommands); + + // Call + bool isChecked = command.Checked; + + // Assert + Assert.IsFalse(isChecked); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenMapViewCommandTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenMapViewCommandTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenMapViewCommandTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,84 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Controls.Commands; +using Core.Common.Gui.Commands; +using Demo.Riskeer.Commands; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Demo.Riskeer.Test.Commands +{ + [TestFixture] + public class OpenMapViewCommandTest + { + [Test] + public void ParameteredConstructor_DefaultValues() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var command = new OpenMapViewCommand(viewCommands); + + // Assert + Assert.IsInstanceOf(command); + Assert.IsFalse(command.Checked); + mocks.VerifyAll(); + } + + [Test] + public void Execute_Always_OpensViewForMapData() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.StrictMock(); + viewCommands.Expect(g => g.OpenView(Arg.Is.NotNull)); + mocks.ReplayAll(); + + var command = new OpenMapViewCommand(viewCommands); + + // Call + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void Checked_Always_ReturnsFalse() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var command = new OpenMapViewCommand(viewCommands); + + // Assert + Assert.IsFalse(command.Checked); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenPointedTreeGraphViewCommandTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenPointedTreeGraphViewCommandTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenPointedTreeGraphViewCommandTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,68 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Gui.Commands; +using Demo.Riskeer.Commands; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Demo.Riskeer.Test.Commands +{ + [TestFixture] + public class OpenPointedTreeGraphViewCommandTest + { + [Test] + public void Execute_Always_OpensViewForGraphNode() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.StrictMock(); + viewCommands.Expect(g => g.OpenView(Arg.Is.NotNull)); + mocks.ReplayAll(); + + var command = new OpenPointedTreeGraphViewCommand(viewCommands); + + // Call + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void Checked_Always_ReturnsFalse() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + var command = new OpenPointedTreeGraphViewCommand(viewCommands); + + // Call + bool isChecked = command.Checked; + + // Assert + Assert.IsFalse(isChecked); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenStackChartViewCommandTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenStackChartViewCommandTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenStackChartViewCommandTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,68 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Gui.Commands; +using Demo.Riskeer.Commands; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Demo.Riskeer.Test.Commands +{ + [TestFixture] + public class OpenStackChartViewCommandTest + { + [Test] + public void Execute_Always_OpensViewForIChartData() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.StrictMock(); + viewCommands.Expect(g => g.OpenView(Arg.Is.NotNull)); + mocks.ReplayAll(); + + var command = new OpenStackChartViewCommand(viewCommands); + + // Call + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void Checked_Always_ReturnsFalse() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + var command = new OpenStackChartViewCommand(viewCommands); + + // Call + bool isChecked = command.Checked; + + // Assert + Assert.IsFalse(isChecked); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenThematicalMapViewCommandTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenThematicalMapViewCommandTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Commands/OpenThematicalMapViewCommandTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,84 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Controls.Commands; +using Core.Common.Gui.Commands; +using Demo.Riskeer.Commands; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Demo.Riskeer.Test.Commands +{ + [TestFixture] + public class OpenThematicalMapViewCommandTest + { + [Test] + public void ParameteredConstructor_DefaultValues() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var command = new OpenThematicalMapViewCommand(viewCommands); + + // Assert + Assert.IsInstanceOf(command); + Assert.IsFalse(command.Checked); + mocks.VerifyAll(); + } + + [Test] + public void Execute_Always_OpensViewForMapData() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.StrictMock(); + viewCommands.Expect(g => g.OpenView(Arg.Is.NotNull)); + mocks.ReplayAll(); + + var command = new OpenThematicalMapViewCommand(viewCommands); + + // Call + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void Checked_Always_ReturnsFalse() + { + // Setup + var mocks = new MockRepository(); + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var command = new OpenThematicalMapViewCommand(viewCommands); + + // Assert + Assert.IsFalse(command.Checked); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Demo.Riskeer.Test.csproj =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Demo.Riskeer.Test.csproj (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Demo.Riskeer.Test.csproj (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,179 @@ + + + + {C48E2C11-3FDA-4356-A10F-757469A108FD} + Demo.Riskeer.Test + Demo.Riskeer.Test + + + + + ..\..\..\..\packages\Fluent.Ribbon.3.4.0\lib\net40\Fluent.dll + True + + + ..\..\..\..\packages\NUnit.3.8.1\lib\net40\nunit.framework.dll + True + + + + + ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + {3bbfd65b-b277-4e50-ae6d-bd24c3434609} + Core.Common.Base + + + {9a2d67e6-26ac-4d17-b11a-2b4372f2f572} + Core.Common.Controls + + + {30e4c2ae-719e-4d70-9fa9-668a9767fbfa} + Core.Common.Gui + + + {2465cca1-c505-4827-9454-4fd5fd9194cd} + Core.Components.Chart.Forms + + + {516EBC95-B8F2-428C-B7F6-733F01BF8FDD} + Core.Components.Chart + + + {5A91174A-FB95-4C9D-9CA5-81C0B8D4361A} + Core.Components.DotSpatial.Forms + + + {4a06df0d-5d75-4bad-a95a-a3db9b7c4ad5} + Core.Components.Gis.Forms + + + {318ba582-88c9-4816-a54a-a7e431461de3} + Core.Components.Gis + + + {4E575459-AD64-4F5F-B313-9F8E0EC8C03F} + Core.Components.GraphSharp.Forms + + + {DADAA0A5-288C-49CB-9F08-337F16832C86} + Core.Components.OxyPlot.Forms + + + {dbf5a590-2a11-4eb4-a8cc-f3036475e4d5} + Core.Components.PointedTree.Forms + + + {AD3B1634-C435-4618-9971-2EA0817F5DE2} + Core.Components.PointedTree + + + {72109e33-6518-4632-accf-6cbf2a312711} + Core.Components.Stack.Forms + + + {6A146889-A3C4-48BF-AF53-C0B0CD355BE4} + Core.Components.Stack + + + {C6309704-D67B-434C-BC98-9F8910BC1D10} + Ringtoets.ClosingStructures.Data + + + {d4200f43-3f72-4f42-af0a-8ced416a38ec} + Ringtoets.Common.Data + + + {4843D6E5-066F-4795-94F5-1D53932DD03C} + Ringtoets.Common.Data.TestUtil + + + {90de728e-48ef-4665-ab38-3d88e41d9f4d} + Ringtoets.GrassCoverErosionInwards.Data + True + + + {E7225477-577F-4A17-B7EC-6721158E1543} + Ringtoets.GrassCoverErosionOutwards.Data + + + {1c0017d8-35b5-4ca0-8fc7-a83f46dbdc99} + Ringtoets.HeightStructures.Data + + + {11f1f874-45af-43e4-8ae5-15a5c9593e28} + Ringtoets.Integration.Data + + + {ce994cc9-6f6a-48ac-b4be-02c30a21f4db} + Ringtoets.Piping.Data + + + {14C6F716-64E2-4BC4-A1EF-05865FCEFA4C} + Ringtoets.Piping.Primitives + + + {10B8D63D-87E8-46DF-ACA9-A8CF22EE8FB5} + Ringtoets.Piping.Service + + + {87c2c553-c0bc-40bf-b1ea-b83bff357f27} + Ringtoets.Revetment.Data + + + {3D4B9740-8348-4434-8D77-B611FC6EE57F} + Ringtoets.StabilityPointStructures.Data + + + {B479E3AF-7C34-488C-BB73-D324100D36C9} + Ringtoets.StabilityStoneCover.Data + + + {567E0B69-5280-41CE-ADD6-443725A61C86} + Ringtoets.WaveImpactAsphaltCover.Data + + + {ffe3a667-3a4c-4f48-bc6b-1589867fcb41} + Demo.Riskeer + + + + + Copying.licenseheader + + + Designer + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/GUIs/DemoProjectPluginTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/GUIs/DemoProjectPluginTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/GUIs/DemoProjectPluginTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,98 @@ +// Copyright (C) Stichting Deltares 2018. 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.Linq; +using System.Threading; +using Core.Common.Gui; +using Core.Common.Gui.Forms; +using Core.Common.Gui.Plugin; +using Core.Components.Chart.Data; +using Core.Components.Gis.Data; +using Core.Components.PointedTree.Data; +using Core.Components.Stack.Data; +using Demo.Riskeer.GUIs; +using Demo.Riskeer.Views; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Demo.Riskeer.Test.GUIs +{ + [TestFixture] + public class DemoProjectPluginTest + { + [Test] + [Apartment(ApartmentState.STA)] + public void DefaultConstructor_DefaultValues() + { + // Setup + var mocks = new MockRepository(); + var gui = mocks.Stub(); + mocks.ReplayAll(); + + // Call + using (var plugin = new DemoProjectPlugin + { + Gui = gui + }) + { + // Assert + Assert.IsInstanceOf(plugin); + Assert.IsInstanceOf(plugin.RibbonCommandHandler); + } + + mocks.VerifyAll(); + } + + [Test] + public void GetViewInfos_ReturnsSupportedViewInfos() + { + // Setup + using (var plugin = new DemoProjectPlugin()) + { + // Call + ViewInfo[] views = plugin.GetViewInfos().ToArray(); + + // Assert + Assert.AreEqual(4, views.Length); + + ViewInfo chartViewInfo = views[0]; + Assert.AreEqual(typeof(ChartDataCollection), chartViewInfo.DataType); + Assert.AreEqual(typeof(ChartDataView), chartViewInfo.ViewType); + Assert.AreEqual("Diagram", chartViewInfo.GetViewName(null, null)); + + ViewInfo mapViewInfo = views[1]; + Assert.AreEqual(typeof(MapData), mapViewInfo.DataType); + Assert.AreEqual(typeof(MapDataView), mapViewInfo.ViewType); + Assert.AreEqual("Kaart", mapViewInfo.GetViewName(null, null)); + + ViewInfo stackChartViewInfo = views[2]; + Assert.AreEqual(typeof(StackChartData), stackChartViewInfo.DataType); + Assert.AreEqual(typeof(StackChartDataView), stackChartViewInfo.ViewType); + Assert.AreEqual("Diagram", stackChartViewInfo.GetViewName(null, null)); + + ViewInfo pointedTreeGraphViewInfo = views[3]; + Assert.AreEqual(typeof(GraphNode), pointedTreeGraphViewInfo.DataType); + Assert.AreEqual(typeof(PointedTreeGraphView), pointedTreeGraphViewInfo.ViewType); + Assert.AreEqual("Foutenboom", pointedTreeGraphViewInfo.GetViewName(null, null)); + } + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Properties/AssemblyInfo.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Properties/AssemblyInfo.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Properties/AssemblyInfo.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,25 @@ +// Copyright (C) Stichting Deltares 2018. 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.Reflection; + +[assembly: AssemblyTitle("Demo.Riskeer.Test")] +[assembly: AssemblyProduct("Demo.Riskeer.Test")] \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Ribbons/RingtoetsDemoProjectRibbonTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Ribbons/RingtoetsDemoProjectRibbonTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Ribbons/RingtoetsDemoProjectRibbonTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,183 @@ +// Copyright (C) Stichting Deltares 2018. 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.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using Core.Common.Gui; +using Core.Common.Gui.Commands; +using NUnit.Framework; +using Rhino.Mocks; +using RingtoetsDemoProjectRibbon = Demo.Riskeer.Ribbons.RingtoetsDemoProjectRibbon; + +namespace Demo.Riskeer.Test.Ribbons +{ + [TestFixture] + public class RingtoetsDemoProjectRibbonTest + { + [Test] + [Apartment(ApartmentState.STA)] + public void DefaultConstructor_Always_CreatesControl() + { + // Setup + var mocks = new MockRepository(); + var projectOwner = mocks.Stub(); + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var ribbon = new RingtoetsDemoProjectRibbon(projectOwner, viewCommands); + + // Assert + Assert.IsNotNull(ribbon); + Assert.IsInstanceOf(ribbon.GetRibbonControl()); + mocks.VerifyAll(); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void OpenChartViewButton_OnClick_ExecutesOpenChartViewCommand() + { + // Setup + var mocks = new MockRepository(); + var projectOwner = mocks.Stub(); + var viewCommands = mocks.Stub(); + viewCommands.Expect(vc => vc.OpenView(null)).IgnoreArguments(); + + mocks.ReplayAll(); + + var ribbon = new RingtoetsDemoProjectRibbon(projectOwner, viewCommands); + var button = ribbon.GetRibbonControl().FindName("OpenChartViewButton") as Button; + + // Precondition + Assert.IsNotNull(button, "Ribbon should have an open chart view button."); + + // Call + button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + + // Assert + mocks.VerifyAll(); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void OpenMapViewButton_OnClick_OpensView() + { + // Setup + var mocks = new MockRepository(); + var projectOwner = mocks.Stub(); + var viewCommands = mocks.Stub(); + viewCommands.Expect(vc => vc.OpenView(null)).IgnoreArguments(); + + mocks.ReplayAll(); + + var ribbon = new RingtoetsDemoProjectRibbon(projectOwner, viewCommands); + + var button = ribbon.GetRibbonControl().FindName("OpenMapViewButton") as Button; + + // Precondition + Assert.IsNotNull(button, "Ribbon should have an open map view button"); + + // Call + button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + + // Assert + mocks.VerifyAll(); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void OpenThematicMapViewButton_OnClick_OpensView() + { + // Setup + var mocks = new MockRepository(); + var projectOwner = mocks.Stub(); + var viewCommands = mocks.Stub(); + viewCommands.Expect(vc => vc.OpenView(null)).IgnoreArguments(); + + mocks.ReplayAll(); + + var ribbon = new RingtoetsDemoProjectRibbon(projectOwner, viewCommands); + + var button = ribbon.GetRibbonControl().FindName("OpenThematicMapViewButton") as Button; + + // Precondition + Assert.IsNotNull(button, "Ribbon should have an open thematic map view button"); + + // Call + button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + + // Assert + mocks.VerifyAll(); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void OpenStackChartViewButton_OnClick_ExecutesOpenStackChartViewCommand() + { + // Setup + var mocks = new MockRepository(); + var projectOwner = mocks.Stub(); + var viewCommands = mocks.Stub(); + viewCommands.Expect(vc => vc.OpenView(null)).IgnoreArguments(); + + mocks.ReplayAll(); + + var ribbon = new RingtoetsDemoProjectRibbon(projectOwner, viewCommands); + var button = ribbon.GetRibbonControl().FindName("OpenStackChartViewButton") as Button; + + // Precondition + Assert.IsNotNull(button, "Ribbon should have an open stack chart view button."); + + // Call + button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + + // Assert + mocks.VerifyAll(); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void OpenPointedTreeGraphViewButton_OnClick_ExecutesOpenPointedTreeGraphViewCommand() + { + // Setup + var mocks = new MockRepository(); + var projectOwner = mocks.Stub(); + var viewCommands = mocks.Stub(); + viewCommands.Expect(vc => vc.OpenView(null)).IgnoreArguments(); + + mocks.ReplayAll(); + + var ribbon = new RingtoetsDemoProjectRibbon(projectOwner, viewCommands); + var button = ribbon.GetRibbonControl().FindName("OpenPointedTreeGraphViewButton") as Button; + + // Precondition + Assert.IsNotNull(button, "Ribbon should have an open pointed tree graph view button."); + + // Call + button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Views/ChartDataViewTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Views/ChartDataViewTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Views/ChartDataViewTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2018. 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.Windows.Forms; +using Core.Components.Chart.Data; +using Core.Components.OxyPlot.Forms; +using Demo.Riskeer.Views; +using NUnit.Framework; + +namespace Demo.Riskeer.Test.Views +{ + [TestFixture] + public class ChartDataViewTest + { + [Test] + public void DefaultConstructor_Always_AddsChartControl() + { + // Call + using (var chartView = new ChartDataView()) + { + // Assert + Assert.AreEqual(1, chartView.Controls.Count); + object chartObject = chartView.Controls[0]; + Assert.IsInstanceOf(chartObject); + + var chart = (ChartControl) chartObject; + Assert.AreEqual(DockStyle.Fill, chart.Dock); + Assert.NotNull(chartView.Chart); + } + } + + [Test] + public void Data_SetToObject_DoesNotThrow() + { + // Setup + using (var chartView = new ChartDataView()) + { + // Call + TestDelegate testDelegate = () => chartView.Data = new object(); + + // Assert + Assert.DoesNotThrow(testDelegate); + Assert.IsNull(chartView.Data); + } + } + + [Test] + public void Data_SetToCollectionChartData_ChartDataSet() + { + // Setup + using (var chartView = new ChartDataView()) + { + var chartDataCollection = new ChartDataCollection("test data"); + + // Call + chartView.Data = chartDataCollection; + + // Assert + Assert.AreSame(chartDataCollection, chartView.Data); + } + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Views/MapDataViewTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Views/MapDataViewTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Views/MapDataViewTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,114 @@ +// Copyright (C) Stichting Deltares 2018. 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.Linq; +using System.Windows.Forms; +using Core.Common.Base.Geometry; +using Core.Common.Controls.Views; +using Core.Components.DotSpatial.Forms; +using Core.Components.Gis.Data; +using Core.Components.Gis.Features; +using Core.Components.Gis.Geometries; +using Demo.Riskeer.Views; +using NUnit.Framework; + +namespace Demo.Riskeer.Test.Views +{ + [TestFixture] + public class MapDataViewTest + { + [Test] + public void DefaultConstructor_DefaultValues() + { + // Call + using (var mapView = new MapDataView()) + { + // Assert + Assert.IsInstanceOf(mapView); + Assert.IsInstanceOf(mapView); + } + } + + [Test] + public void DefaultConstructor_Always_AddEmptyMapControl() + { + // Call + using (var view = new MapDataView()) + { + // Assert + Assert.AreEqual(1, view.Controls.Count); + Assert.AreSame(view.Map, view.Controls[0]); + Assert.AreEqual(DockStyle.Fill, ((Control) view.Map).Dock); + Assert.IsNull(view.Map.Data); + } + } + + [Test] + public void Data_SetToObject_DoesNotThrow() + { + // Setup + using (var mapView = new MapDataView()) + { + // Call + TestDelegate testDelegate = () => mapView.Data = new object(); + + // Assert + Assert.DoesNotThrow(testDelegate); + Assert.IsNull(mapView.Data); + } + } + + [Test] + public void Data_SetToMapCollectionData_MapDataSet() + { + // Setup + var features = new[] + { + new MapFeature(new[] + { + new MapGeometry(new[] + { + Enumerable.Empty() + }) + }) + }; + + using (var mapView = new MapDataView()) + { + var map = (MapControl) mapView.Controls[0]; + var collection = new MapDataCollection("test"); + var pointData = new MapPointData("test data") + { + Features = features + }; + + collection.Add(pointData); + + // Call + mapView.Data = collection; + + // Assert + Assert.AreSame(pointData, map.Data.Collection.First()); + Assert.AreSame(collection, mapView.Data); + } + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Views/PointedTreeGraphViewTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Views/PointedTreeGraphViewTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Views/PointedTreeGraphViewTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,84 @@ +// Copyright (C) Stichting Deltares 2018. 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.Threading; +using System.Windows.Forms; +using Core.Components.GraphSharp.Forms; +using Core.Components.PointedTree.Data; +using Demo.Riskeer.Views; +using NUnit.Framework; + +namespace Demo.Riskeer.Test.Views +{ + [TestFixture] + public class PointedTreeGraphViewTest + { + [Test] + [Apartment(ApartmentState.STA)] + public void DefaultConstructor_Always_AddsPointedTreeGraphControl() + { + // Call + using (var view = new PointedTreeGraphView()) + { + // Assert + Assert.AreEqual(1, view.Controls.Count); + object control = view.Controls[0]; + Assert.IsInstanceOf(control); + + var pointedTreeGraph = (PointedTreeGraphControl) control; + Assert.AreEqual(DockStyle.Fill, pointedTreeGraph.Dock); + } + } + + [Test] + [Apartment(ApartmentState.STA)] + public void Data_SetToObject_DoesNotThrow() + { + // Setup + using (var view = new PointedTreeGraphView()) + { + // Call + TestDelegate testDelegate = () => view.Data = new object(); + + // Assert + Assert.DoesNotThrow(testDelegate); + Assert.IsNull(view.Data); + } + } + + [Test] + [Apartment(ApartmentState.STA)] + public void Data_SetToGraphNode_DataSet() + { + // Setup + using (var view = new PointedTreeGraphView()) + { + var graphNode = new GraphNode("Root node", new GraphNode[0], false); + + // Call + view.Data = graphNode; + + // Assert + Assert.AreSame(graphNode, view.Data); + } + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/Views/StackChartDataViewTest.cs =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/Views/StackChartDataViewTest.cs (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/Views/StackChartDataViewTest.cs (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,80 @@ +// Copyright (C) Stichting Deltares 2018. 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.Windows.Forms; +using Core.Components.OxyPlot.Forms; +using Core.Components.Stack.Data; +using Demo.Riskeer.Views; +using NUnit.Framework; + +namespace Demo.Riskeer.Test.Views +{ + [TestFixture] + public class StackChartDataViewTest + { + [Test] + public void DefaultConstructor_Always_AddsChartControl() + { + // Call + using (var chartView = new StackChartDataView()) + { + // Assert + Assert.AreEqual(1, chartView.Controls.Count); + object chartObject = chartView.Controls[0]; + Assert.IsInstanceOf(chartObject); + + var chart = (StackChartControl) chartObject; + Assert.AreEqual(DockStyle.Fill, chart.Dock); + } + } + + [Test] + public void Data_SetToObject_DoesNotThrow() + { + // Setup + using (var chartView = new StackChartDataView()) + { + // Call + TestDelegate testDelegate = () => chartView.Data = new object(); + + // Assert + Assert.DoesNotThrow(testDelegate); + Assert.IsNull(chartView.Data); + } + } + + [Test] + public void Data_SetToStackChartData_DataSet() + { + // Setup + using (var chartView = new StackChartDataView()) + { + var stackChartData = new StackChartData(); + + // Call + chartView.Data = stackChartData; + + // Assert + Assert.AreSame(stackChartData, chartView.Data); + } + } + } +} \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Riskeer.Test/packages.config =================================================================== diff -u --- Demo/Ringtoets/test/Demo.Riskeer.Test/packages.config (revision 0) +++ Demo/Ringtoets/test/Demo.Riskeer.Test/packages.config (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -0,0 +1,28 @@ + + + + + + + \ No newline at end of file Index: Ringtoets.sln =================================================================== diff -u -rc6cb82aaec4a088977f4cc10542c9a892e786b42 -r9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d --- Ringtoets.sln (.../Ringtoets.sln) (revision c6cb82aaec4a088977f4cc10542c9a892e786b42) +++ Ringtoets.sln (.../Ringtoets.sln) (revision 9aacdc444e6a99cc5ad123d39a9d8de582d0eb5d) @@ -438,7 +438,7 @@ {C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Riskeer.Test", "Demo\Ringtoets\test\Demo.Ringtoets.Test\Demo.Riskeer.Test.csproj", "{C48E2C11-3FDA-4356-A10F-757469A108FD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Riskeer.Test", "Demo\Ringtoets\test\Demo.Riskeer.Test\Demo.Riskeer.Test.csproj", "{C48E2C11-3FDA-4356-A10F-757469A108FD}" ProjectSection(ProjectDependencies) = postProject {C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC} EndProjectSection