Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs =================================================================== diff -u -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 -r69ba77aac3b14ca0060f5788121f36f5fd19c83f --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs (.../ClosingStructuresFailureMechanismViewTest.cs) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs (.../ClosingStructuresFailureMechanismViewTest.cs) (revision 69ba77aac3b14ca0060f5788121f36f5fd19c83f) @@ -298,9 +298,9 @@ } [Test] - public void UpdateObserver_AssessmentSectionUpdated_MapDataUpdated() + public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -334,19 +334,19 @@ // Precondition 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 ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -373,11 +373,11 @@ // Precondition MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData); - // Call + // When hydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(2, "test2", 2.0, 3.0)); hydraulicBoundaryDatabase.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData); } } @@ -429,9 +429,9 @@ } [Test] - public void UpdateObserver_ReferenceLineUpdated_MapDataUpdated() + public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -463,19 +463,19 @@ // Precondition 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 ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -489,25 +489,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 ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -532,7 +532,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When var foreshoreProfileToUpdateFrom = new TestForeshoreProfile("originalProfile ID", new[] { new Point2D(2, 2), @@ -541,15 +541,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 ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -573,7 +573,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When failureMechanism.ForeshoreProfiles.AddRange(new[] { new TestForeshoreProfile("newProfile ID", new[] @@ -584,15 +584,15 @@ }, "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 ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -614,20 +614,20 @@ MapDataTestHelper.AssertStructuresMapData(failureMechanism.ClosingStructures, structuresData); - // Call + // When structure.CopyProperties(new TestClosingStructure(new Point2D(1, 1), "Id")); structure.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertStructuresMapData(failureMechanism.ClosingStructures, structuresData); } } [Test] - public void UpdateObserver_StructuresUpdated_MapDataUpdated() + public void GivenViewWithStructuresData_WhenStructuresUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -649,23 +649,23 @@ MapDataTestHelper.AssertStructuresMapData(failureMechanism.ClosingStructures, structuresData); - // Call + // When failureMechanism.ClosingStructures.AddRange(new[] { new TestClosingStructure(new Point2D(1, 1), "Id2") }, "some path"); failureMechanism.ClosingStructures.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertStructuresMapData(failureMechanism.ClosingStructures, structuresData); } } [Test] - public void UpdateObserver_CalculationGroupUpdated_MapDataUpdated() + public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -707,20 +707,19 @@ 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 ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -751,20 +750,19 @@ AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + // When calculationA.InputParameters.Structure = new TestClosingStructure(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 ClosingStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -794,12 +792,11 @@ AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + // When calculationA.Name = "new name"; - - // Call calculationA.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); } }