Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs =================================================================== diff -u -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 -r69ba77aac3b14ca0060f5788121f36f5fd19c83f --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs (.../HeightStructuresFailureMechanismViewTest.cs) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs (.../HeightStructuresFailureMechanismViewTest.cs) (revision 69ba77aac3b14ca0060f5788121f36f5fd19c83f) @@ -297,9 +297,9 @@ } [Test] - public void UpdateObserver_AssessmentSectionUpdated_MapDataUpdated() + public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -335,20 +335,20 @@ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase1.Locations, hydraulicBoundaryLocationsMapData); - // Call + // When assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase2; assessmentSection.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase2.Locations, hydraulicBoundaryLocationsMapData); } } [Test] - public void UpdateObserver_HydraulicBoundaryDatabaseUpdated_MapDataUpdated() + public void GivenViewWithHydraulicBoundaryDatabaseData_WhenHydraulicBoundaryDatabaseUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -377,11 +377,11 @@ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData); - // Call + // When hydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(2, "test2", 3.0, 4.0)); hydraulicBoundaryDatabase.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData); } @@ -437,9 +437,9 @@ } [Test] - public void UpdateObserver_ReferenceLineUpdated_MapDataUpdated() + public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -473,20 +473,20 @@ MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); - // Call + // When assessmentSection.ReferenceLine.SetGeometry(points2); assessmentSection.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); } } [Test] - public void UpdateObserver_FailureMechanismSectionsUpdated_MapDataUpdated() + public void GivenViewWithFailureMechanismSectionsData_WhenFailureMechanismSectionsUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -501,25 +501,25 @@ var sectionStartsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsStartPointIndex); var sectionsEndsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsEndPointIndex); - // Call + // When failureMechanism.AddSection(new FailureMechanismSection(string.Empty, new[] { new Point2D(1, 2), new Point2D(1, 2) })); failureMechanism.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, sectionMapData); MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, sectionStartsMapData); MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, sectionsEndsMapData); } } [Test] - public void UpdateObserver_ForeshoreProfileUpdate_MapDataUpdated() + public void GivenViewWithForeshoreProfileData_WhenForeshoreProfileUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -544,7 +544,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When var foreshoreProfileToUpdateFrom = new TestForeshoreProfile("originalProfile ID", new[] { new Point2D(2, 2), @@ -553,15 +553,15 @@ foreshoreProfile.CopyProperties(foreshoreProfileToUpdateFrom); foreshoreProfile.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); } } [Test] - public void UpdateObserver_ForeshoreProfilesUpdated_MapDataUpdated() + public void GivenViewWithForeshoreProfilesData_WhenForeshoreProfilesUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -587,7 +587,7 @@ MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When failureMechanism.ForeshoreProfiles.AddRange(new[] { new TestForeshoreProfile("newProfile ID", new[] @@ -598,16 +598,16 @@ }, "path"); failureMechanism.ForeshoreProfiles.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); } } [Test] - public void UpdateObserver_StructureUpdated_MapDataUpdated() + public void GivenViewWithStructureData_WhenStructureUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -630,20 +630,20 @@ MapDataTestHelper.AssertStructuresMapData(failureMechanism.HeightStructures, structuresData); - // Call + // When structure.CopyProperties(new TestHeightStructure(new Point2D(1, 1), "Id")); structure.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertStructuresMapData(failureMechanism.HeightStructures, structuresData); } } [Test] - public void UpdateObserver_StructuresUpdated_MapDataUpdated() + public void GivenViewWithStructuresData_WhenStructuresUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -665,23 +665,23 @@ MapDataTestHelper.AssertStructuresMapData(failureMechanism.HeightStructures, structuresData); - // Call + // When failureMechanism.HeightStructures.AddRange(new[] { new TestHeightStructure(new Point2D(1, 1), "Id2") }, "some path"); failureMechanism.HeightStructures.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertStructuresMapData(failureMechanism.HeightStructures, structuresData); } } [Test] - public void UpdateObserver_CalculationGroupUpdated_MapDataUpdated() + public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -724,21 +724,20 @@ AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + // When failureMechanism.CalculationsGroup.Children.Add(calculationB); - - // Call failureMechanism.CalculationsGroup.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); } } [Test] - public void UpdateObserver_CalculationInputUpdated_MapDataUpdated() + public void GivenViewWithCalculationInputData_WhenCalculationInputUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -770,21 +769,20 @@ AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + // When calculationA.InputParameters.Structure = new TestHeightStructure(calculationLocationB); - - // Call calculationA.InputParameters.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); } } [Test] - public void UpdateObserver_CalculationUpdated_MapDataUpdated() + public void GivenViewWithCalculationData_WhenCalculationUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new HeightStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -815,12 +813,11 @@ AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + // When calculationA.Name = "new name"; - - // Call calculationA.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); }