Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismViewTest.cs =================================================================== diff -u -r6e2155502980cd3a7654eba3004aebadbe40b1e4 -r03121b2f30c14ca0a0312f496bcb14b1d328525b --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismViewTest.cs (.../MacroStabilityInwardsFailureMechanismViewTest.cs) (revision 6e2155502980cd3a7654eba3004aebadbe40b1e4) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismViewTest.cs (.../MacroStabilityInwardsFailureMechanismViewTest.cs) (revision 03121b2f30c14ca0a0312f496bcb14b1d328525b) @@ -63,10 +63,24 @@ private const int calculationsIndex = 7; [Test] + public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new MacroStabilityInwardsFailureMechanismView(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + } + + [Test] public void Constructor_ExpectedValues() { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + // Call - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism)) { // Assert Assert.IsInstanceOf(view); @@ -85,7 +99,7 @@ public void Data_MacroStabilityInwardsFailureMechanismContext_DataSet() { // Setup - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { var assessmentSection = new ObservableTestAssessmentSectionStub(); @@ -104,7 +118,7 @@ public void Data_OtherThanMacroStabilityInwardsFailureMechanismContext_DataNull() { // Setup - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { var data = new object(); @@ -120,7 +134,7 @@ public void Data_SetToNull_MapDataCleared() { // Setup - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { var assessmentSection = new ObservableTestAssessmentSectionStub(); @@ -147,7 +161,7 @@ // Setup var assessmentSection = new ObservableTestAssessmentSectionStub(); - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext( new MacroStabilityInwardsFailureMechanism(), assessmentSection); @@ -168,7 +182,7 @@ // Setup var assessmentSection = new ObservableTestAssessmentSectionStub(); - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), assessmentSection); @@ -191,7 +205,7 @@ }; using (new UseCustomTileSourceFactoryConfig(backgroundMapData)) - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { view.Data = new MacroStabilityInwardsFailureMechanismContext( new MacroStabilityInwardsFailureMechanism(), assessmentSection); @@ -213,90 +227,90 @@ public void Data_MacroStabilityInwardsFailureMechanismContext_DataUpdatedToCollectionOfFilledMapData() { // Setup - using (var view = new MacroStabilityInwardsFailureMechanismView()) - { - IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; - - var geometryPoints = new[] - { - new Point2D(0.0, 0.0), - new Point2D(2.0, 0.0), - new Point2D(4.0, 4.0), - new Point2D(6.0, 4.0) - }; - - var referenceLine = new ReferenceLine(); - referenceLine.SetGeometry(new[] - { - new Point2D(0.0, 3.0), - new Point2D(3.0, 0.0) - }); - - var assessmentSection = new ObservableTestAssessmentSectionStub - { - HydraulicBoundaryDatabase = - { - Locations = - { - new HydraulicBoundaryLocation(1, "test", 1.0, 2.0) - } - }, - ReferenceLine = referenceLine - }; - - MacroStabilityInwardsStochasticSoilModel stochasticSoilModel1 = + MacroStabilityInwardsStochasticSoilModel stochasticSoilModel1 = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("name1", new[] { new Point2D(1.0, 2.0), new Point2D(1.1, 2.2) }); - MacroStabilityInwardsStochasticSoilModel stochasticSoilModel2 = - MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("name2", new[] - { + MacroStabilityInwardsStochasticSoilModel stochasticSoilModel2 = + MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("name2", new[] + { new Point2D(3.0, 4.0), new Point2D(3.3, 4.4) - }); + }); - var surfaceLineA = new MacroStabilityInwardsSurfaceLine("Line A"); - surfaceLineA.SetGeometry(new[] - { + var surfaceLineA = new MacroStabilityInwardsSurfaceLine("Line A"); + surfaceLineA.SetGeometry(new[] + { new Point3D(0.0, 0.0, 1.0), new Point3D(3.0, 0.0, 1.7) }); - var surfaceLineB = new MacroStabilityInwardsSurfaceLine("Name B"); - surfaceLineB.SetGeometry(new[] - { + var surfaceLineB = new MacroStabilityInwardsSurfaceLine("Name B"); + surfaceLineB.SetGeometry(new[] + { new Point3D(0.0, 0.0, 1.5), new Point3D(3.0, 0.0, 1.8) }); - surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3); - surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5); + surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3); + surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5); - var failureMechanism = new MacroStabilityInwardsFailureMechanism(); - const string arbitraryFilePath = "path"; - failureMechanism.SurfaceLines.AddRange(new[] - { + var geometryPoints = new[] + { + new Point2D(0.0, 0.0), + new Point2D(2.0, 0.0), + new Point2D(4.0, 4.0), + new Point2D(6.0, 4.0) + }; + + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + const string arbitraryFilePath = "path"; + failureMechanism.SurfaceLines.AddRange(new[] + { surfaceLineA, surfaceLineB }, arbitraryFilePath); - failureMechanism.AddSection(new FailureMechanismSection("A", geometryPoints.Take(2))); - failureMechanism.AddSection(new FailureMechanismSection("B", geometryPoints.Skip(1).Take(2))); - failureMechanism.AddSection(new FailureMechanismSection("C", geometryPoints.Skip(2).Take(2))); - failureMechanism.StochasticSoilModels.AddRange(new[] - { + failureMechanism.AddSection(new FailureMechanismSection("A", geometryPoints.Take(2))); + failureMechanism.AddSection(new FailureMechanismSection("B", geometryPoints.Skip(1).Take(2))); + failureMechanism.AddSection(new FailureMechanismSection("C", geometryPoints.Skip(2).Take(2))); + failureMechanism.StochasticSoilModels.AddRange(new[] + { stochasticSoilModel1, stochasticSoilModel2 }, arbitraryFilePath); - MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(); - calculationA.InputParameters.SurfaceLine = surfaceLineA; - MacroStabilityInwardsCalculationScenario calculationB = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(); - calculationB.InputParameters.SurfaceLine = surfaceLineB; - failureMechanism.CalculationsGroup.Children.Add(calculationA); - failureMechanism.CalculationsGroup.Children.Add(calculationB); + MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(); + calculationA.InputParameters.SurfaceLine = surfaceLineA; + MacroStabilityInwardsCalculationScenario calculationB = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(); + calculationB.InputParameters.SurfaceLine = surfaceLineB; + failureMechanism.CalculationsGroup.Children.Add(calculationA); + failureMechanism.CalculationsGroup.Children.Add(calculationB); + using (var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism)) + { + IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + + var referenceLine = new ReferenceLine(); + referenceLine.SetGeometry(new[] + { + new Point2D(0.0, 3.0), + new Point2D(3.0, 0.0) + }); + + var assessmentSection = new ObservableTestAssessmentSectionStub + { + HydraulicBoundaryDatabase = + { + Locations = + { + new HydraulicBoundaryLocation(1, "test", 1.0, 2.0) + } + }, + ReferenceLine = referenceLine + }; + var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection); // Call @@ -325,7 +339,7 @@ public void GivenViewWithHydraulicBoundaryLocationsData_WhenHydraulicBoundaryLocationsUpdatedAndNotified_ThenMapDataUpdated() { // Given - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -367,7 +381,7 @@ { // Given var random = new Random(21); - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -414,7 +428,7 @@ public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated() { // Given - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -469,7 +483,7 @@ public void GivenViewWithSurfaceLinesData_WhenSurfaceLinesUpdatedAndNotified_ThenMapDataUpdatedAndObserverNotified() { // Given - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; var failureMechanism = new MacroStabilityInwardsFailureMechanism(); @@ -510,15 +524,16 @@ public void GivenViewWithSurfaceLineData_WhenSurfaceLineUpdatedAndNotified_ThenMapDataUpdatedAndObserverNotified() { // Given - using (var view = new MacroStabilityInwardsFailureMechanismView()) + var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + failureMechanism.SurfaceLines.AddRange(new[] { + surfaceLine + }, "path"); + + using (var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism)) + { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; - var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); - var failureMechanism = new MacroStabilityInwardsFailureMechanism(); - failureMechanism.SurfaceLines.AddRange(new[] - { - surfaceLine - }, "path"); var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub()); view.Data = failureMechanismContext; @@ -547,7 +562,7 @@ public void GivenViewWithFailureMechanismSectionsData_WhenFailureMechanismSectionsUpdatedAndNotified_ThenMapDataUpdated() { // Given - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -592,11 +607,12 @@ public void GivenViewWithStochasticSoilModels_WhenStochasticSoilModelsUpdatedAndNotified_ThenMapDataUpdatedAndObserverNotified() { // Given - using (var view = new MacroStabilityInwardsFailureMechanismView()) + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + using (var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism)) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; - var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub()); MacroStabilityInwardsStochasticSoilModel stochasticSoilModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("", new[] @@ -631,11 +647,12 @@ public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated() { // Given - using (var view = new MacroStabilityInwardsFailureMechanismView()) + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + using (var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism)) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; - var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub()); var surfaceLineA = new MacroStabilityInwardsSurfaceLine(string.Empty); @@ -683,31 +700,32 @@ public void GivenViewWithCalculationInputData_WhenCalculationInputUpdatedAndNotified_ThenMapDataUpdated() { // Given - using (var view = new MacroStabilityInwardsFailureMechanismView()) + var surfaceLineA = new MacroStabilityInwardsSurfaceLine(string.Empty); + surfaceLineA.SetGeometry(new[] { - IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + new Point3D(0.0, 0.0, 1.0), + new Point3D(3.0, 0.0, 1.7) + }); + surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3); - var surfaceLineA = new MacroStabilityInwardsSurfaceLine(string.Empty); - surfaceLineA.SetGeometry(new[] - { - new Point3D(0.0, 0.0, 1.0), - new Point3D(3.0, 0.0, 1.7) - }); + MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(); + calculationA.InputParameters.SurfaceLine = surfaceLineA; + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculationA); + + using (var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism)) + { + IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + var surfaceLineB = new MacroStabilityInwardsSurfaceLine(string.Empty); surfaceLineB.SetGeometry(new[] { new Point3D(0.0, 0.0, 1.5), new Point3D(3.0, 0.0, 1.8) }); - surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3); surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5); - MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(); - calculationA.InputParameters.SurfaceLine = surfaceLineA; - - var failureMechanism = new MacroStabilityInwardsFailureMechanism(); - failureMechanism.CalculationsGroup.Children.Add(calculationA); var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub()); view.Data = failureMechanismContext; @@ -733,31 +751,24 @@ public void GivenViewWithCalculationData_WhenCalculationUpdatedAndNotified_ThenMapDataUpdated() { // Given - using (var view = new MacroStabilityInwardsFailureMechanismView()) + var surfaceLineA = new MacroStabilityInwardsSurfaceLine(string.Empty); + surfaceLineA.SetGeometry(new[] { - IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + new Point3D(0.0, 0.0, 1.0), + new Point3D(3.0, 0.0, 1.7) + }); + surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3); - var surfaceLineA = new MacroStabilityInwardsSurfaceLine(string.Empty); - surfaceLineA.SetGeometry(new[] - { - new Point3D(0.0, 0.0, 1.0), - new Point3D(3.0, 0.0, 1.7) - }); + MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(); + calculationA.InputParameters.SurfaceLine = surfaceLineA; - var surfaceLineB = new MacroStabilityInwardsSurfaceLine(string.Empty); - surfaceLineB.SetGeometry(new[] - { - new Point3D(0.0, 0.0, 1.5), - new Point3D(3.0, 0.0, 1.8) - }); - surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3); - surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculationA); - MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(); - calculationA.InputParameters.SurfaceLine = surfaceLineA; + using (var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism)) + { + IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; - var failureMechanism = new MacroStabilityInwardsFailureMechanism(); - failureMechanism.CalculationsGroup.Children.Add(calculationA); var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub()); view.Data = failureMechanismContext; @@ -792,13 +803,12 @@ const int updatedStochasticSoilModelsLayerIndex = stochasticSoilModelsIndex - 1; const int updatedCalculationsIndex = calculationsIndex - 1; - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; var assessmentSection = new ObservableTestAssessmentSectionStub(); - var failureMechanism = new MacroStabilityInwardsFailureMechanism(); - var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), assessmentSection); view.Data = failureMechanismContext; @@ -890,7 +900,7 @@ var oldMacroStabilityInwardsFailureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), oldAssessmentSection); var newMacroStabilityInwardsFailureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), newAssessmentSection); - using (var view = new MacroStabilityInwardsFailureMechanismView()) + using (var view = new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism())) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;