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); } } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismViewTest.cs =================================================================== diff -u -raeb6e1a439617630e7613b9ed5af152c345fa2c6 -r69ba77aac3b14ca0060f5788121f36f5fd19c83f --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismViewTest.cs (.../GrassCoverErosionInwardsFailureMechanismViewTest.cs) (revision aeb6e1a439617630e7613b9ed5af152c345fa2c6) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismViewTest.cs (.../GrassCoverErosionInwardsFailureMechanismViewTest.cs) (revision 69ba77aac3b14ca0060f5788121f36f5fd19c83f) @@ -286,9 +286,9 @@ } [Test] - public void NotifyObservers_AssessmentSectionUpdated_MapDataUpdated() + public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -334,22 +334,21 @@ // Precondition MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase1.Locations, hydraulicBoundaryLocationsMapData); + // When assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase2; - - // Call assessmentSection.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase2.Locations, hydraulicBoundaryLocationsMapData); mocks.VerifyAll(); } } [Test] - public void NotifyObservers_HydraulicBoundaryDatabaseUpdated_MapDataUpdated() + public void GivenViewWithHydraulicBoundaryDatabaseData_WhenHydraulicBoundaryDatabaseUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -381,14 +380,12 @@ // Precondition MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData); + // When hydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(2, "test2", 3.0, 4.0)); - - // Call hydraulicBoundaryDatabase.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData); - mocks.VerifyAll(); } } @@ -454,9 +451,9 @@ } [Test] - public void NotifyObservers_ReferenceLineUpdated_MapDataUpdated() + public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -500,21 +497,20 @@ // Precondition MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); + // When assessmentSection.ReferenceLine.SetGeometry(points2); - - // Call assessmentSection.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); mocks.VerifyAll(); } } [Test] - public void NotifyObservers_FailureMechanismSectionsUpdated_MapDataUpdated() + public void GivenViewWithFailureMechanismSectionsData_WhenFailureMechanismSectionsUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -540,28 +536,26 @@ observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); + // When failureMechanism.AddSection(new FailureMechanismSection(string.Empty, new[] { new Point2D(1, 2), new Point2D(1, 2) })); - - // Call failureMechanism.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, sectionMapData); MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, sectionStartsMapData); MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, sectionsEndsMapData); - mocks.VerifyAll(); } } [Test] - public void NotifyObservers_DikeProfilesUpdated_MapDataUpdated() + public void GivenViewWithDikeProfilesData_WhenDikeProfilesUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -586,24 +580,23 @@ // Precondition AssertDikeProfiles(failureMechanism.DikeProfiles, dikeProfileData); + // When failureMechanism.DikeProfiles.AddRange(new[] { new TestDikeProfile(string.Empty, "id2") }, "path"); - - // Call failureMechanism.DikeProfiles.NotifyObservers(); - // Assert + // Then AssertDikeProfiles(failureMechanism.DikeProfiles, dikeProfileData); mocks.VerifyAll(); } } [Test] - public void NotifyObservers_DikeProfileUpdated_MapDataUpdated() + public void GivenViewWithDikeProfileData_WhenDikeProfileUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -630,22 +623,21 @@ // Precondition AssertDikeProfiles(failureMechanism.DikeProfiles, dikeProfileData); + // When var dikeProfileToUpdateFrom = new TestDikeProfile("A new name", "id1"); dikeProfile.CopyProperties(dikeProfileToUpdateFrom); - - // Call dikeProfile.NotifyObservers(); - // Assert + // Then AssertDikeProfiles(failureMechanism.DikeProfiles, dikeProfileData); mocks.VerifyAll(); } } [Test] - public void NotifyObservers_ForeshoreProfilesUpdated_MapDataUpdated() + public void GivenViewWithForeshoreProfileData_WhenForeshoreProfileUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -676,28 +668,25 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.DikeProfiles.Select(dp => dp.ForeshoreProfile), dikeProfileData); + // When var dikeProfileToUpdateFrom = new TestDikeProfile(new[] { new Point2D(2, 2), new Point2D(3, 3) }, "id1"); - dikeProfile.CopyProperties(dikeProfileToUpdateFrom); - - // Call failureMechanism.DikeProfiles.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.DikeProfiles.Select(dp => dp.ForeshoreProfile), dikeProfileData); - mocks.VerifyAll(); } } [Test] - public void UpdateObserver_CalculationGroupUpdated_MapDataUpdated() + public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -734,22 +723,20 @@ observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); + // When failureMechanism.CalculationsGroup.Children.Add(calculationB); - - // Call failureMechanism.CalculationsGroup.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); - mocks.VerifyAll(); } } [Test] - public void UpdateObserver_CalculationInputUpdated_MapDataUpdated() + public void GivenViewWithCalculationInputData_WhenCalculationInputUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -778,22 +765,20 @@ observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); + // When calculationA.InputParameters.DikeProfile = dikeProfileB; - - // Call calculationA.InputParameters.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); - mocks.VerifyAll(); } } [Test] - public void UpdateObserver_CalculationUpdated_MapDataUpdated() + public void GivenViewWithCalculationData_WhenCalculationUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionInwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -821,14 +806,12 @@ observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); + // When calculationA.Name = "new name"; - - // Call calculationA.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); - mocks.VerifyAll(); } } Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs =================================================================== diff -u -rcc16af254f77623b35c173044f937cebd3e442a2 -r69ba77aac3b14ca0060f5788121f36f5fd19c83f --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewTest.cs) (revision cc16af254f77623b35c173044f937cebd3e442a2) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewTest.cs) (revision 69ba77aac3b14ca0060f5788121f36f5fd19c83f) @@ -279,9 +279,9 @@ } [Test] - public void UpdateObserver_HydraulicBoundaryLocationsUpdated_MapDataUpdated() + public void GivenViewWithHydraulicBoundaryDatabaseData_WhenHydraulicBoundaryDatabaseUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionOutwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -303,19 +303,19 @@ // Precondition MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(failureMechanism.HydraulicBoundaryLocations, hydraulicBoundaryLocationsMapData); - // Call + // When failureMechanism.HydraulicBoundaryLocations.Add(new HydraulicBoundaryLocation(2, "test2", 3.0, 4.0)); failureMechanism.HydraulicBoundaryLocations.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(failureMechanism.HydraulicBoundaryLocations, hydraulicBoundaryLocationsMapData); } } [Test] - public void UpdateObserver_ReferenceLineUpdated_MapDataUpdated() + public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionOutwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -347,19 +347,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 GrassCoverErosionOutwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -373,28 +373,28 @@ 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 GrassCoverErosionOutwardsFailureMechanismView()) { - IMapControl map = ((RingtoetsMapControl)view.Controls[0]).MapControl; + IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var failureMechanismContext = new GrassCoverErosionOutwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub()); @@ -416,7 +416,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When var foreshoreProfileToUpdateFrom = new TestForeshoreProfile("originalProfile ID", new[] { new Point2D(2, 2), @@ -425,15 +425,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 GrassCoverErosionOutwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -457,7 +457,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When failureMechanism.ForeshoreProfiles.AddRange(new[] { new TestForeshoreProfile("newProfile ID", new[] @@ -468,15 +468,15 @@ }, "path"); failureMechanism.ForeshoreProfiles.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); } } [Test] - public void UpdateObserver_CalculationGroupUpdated_MapDataUpdated() + public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new GrassCoverErosionOutwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -512,20 +512,19 @@ // Precondition AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); + // When failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculationB); - - // Call failureMechanism.WaveConditionsCalculationGroup.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 GrassCoverErosionOutwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -552,20 +551,19 @@ // Precondition AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); + // When calculationA.InputParameters.ForeshoreProfile = foreshoreProfileB; - - // 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 GrassCoverErosionOutwardsFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -591,12 +589,11 @@ // Precondition AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); + // When calculationA.Name = "new name"; - - // Call calculationA.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); } } 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); } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r69ba77aac3b14ca0060f5788121f36f5fd19c83f --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs (.../PipingFailureMechanismViewTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs (.../PipingFailureMechanismViewTest.cs) (revision 69ba77aac3b14ca0060f5788121f36f5fd19c83f) @@ -337,9 +337,9 @@ } [Test] - public void UpdateObserver_AssessmentSectionUpdated_MapDataUpdatedAndObserversNotified() + public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new PipingFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -384,21 +384,20 @@ // Precondition MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase1.Locations, hydraulicBoundaryLocationsMapData); + // When assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase2; - - // Call assessmentSection.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase2.Locations, hydraulicBoundaryLocationsMapData); mocks.VerifyAll(); } } [Test] - public void UpdateObserver_HydraulicBoundaryDatabaseUpdated_MapDataUpdatedAndObserversNotified() + public void GivenViewWithHydraulicBoundaryDatabaseData_WhenHydraulicBoundaryDatabaseUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new PipingFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -428,11 +427,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); mocks.VerifyAll(); } @@ -498,9 +497,9 @@ } [Test] - public void UpdateObserver_ReferenceLineUpdated_MapDataUpdatedAndObserverNotified() + public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new PipingFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -542,21 +541,20 @@ // Precondition MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); + // When assessmentSection.ReferenceLine.SetGeometry(points2); - - // Call assessmentSection.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData); mocks.VerifyAll(); } } [Test] - public void UpdateObserver_SurfaceLinesUpdated_MapDataUpdatedAndObserverNotified() + public void GivenViewWithSurfaceLinesData_WhenSurfaceLinesUpdatedAndNotified_ThenMapDataUpdatedAndObserverNotified() { - // Setup + // Given using (var view = new PipingFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -576,29 +574,28 @@ var surfaceLineMapData = (MapLineData) map.Data.Collection.ElementAt(surfaceLinesIndex); - failureMechanism.SurfaceLines.AddRange(new[] - { - surfaceLine - }, "path"); - var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); - // Call + // When + failureMechanism.SurfaceLines.AddRange(new[] + { + surfaceLine + }, "path"); failureMechanism.SurfaceLines.NotifyObservers(); - // Assert + // Then AssertSurfacelinesMapData(failureMechanism.SurfaceLines, surfaceLineMapData); mocks.VerifyAll(); } } [Test] - public void UpdateObserver_SurfaceLineUpdated_MapDataUpdatedAndObserverNotified() + public void GivenViewWithSurfaceLineData_WhenSurfaceLineUpdatedAndNotified_ThenMapDataUpdatedAndObserverNotified() { - // Setup + // Given using (var view = new PipingFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -612,31 +609,30 @@ view.Data = failureMechanismContext; - surfaceLine.SetGeometry(new[] - { - new Point3D(7, 8, 9), - new Point3D(10, 11, 12) - }); - var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); - // Call + // When + surfaceLine.SetGeometry(new[] + { + new Point3D(7, 8, 9), + new Point3D(10, 11, 12) + }); surfaceLine.NotifyObservers(); - // Assert + // Then var surfaceLineMapData = (MapLineData) map.Data.Collection.ElementAt(surfaceLinesIndex); AssertSurfacelinesMapData(failureMechanism.SurfaceLines, surfaceLineMapData); mocks.VerifyAll(); } } [Test] - public void UpdateObserver_FailureMechanismSectionsUpdated_MapDataUpdatedAndObserverNotified() + public void GivenViewWithFailureMechanismSectionsData_WhenFailureMechanismSectionsUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new PipingFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -650,12 +646,6 @@ var sectionStartsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsStartPointIndex); var sectionsEndsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsEndPointIndex); - failureMechanism.AddSection(new FailureMechanismSection(string.Empty, new[] - { - new Point2D(1, 2), - new Point2D(1, 2) - })); - var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[referenceLineIndex].Expect(obs => obs.UpdateObserver()); @@ -668,10 +658,15 @@ observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); - // 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); @@ -680,9 +675,9 @@ } [Test] - public void UpdateObserver_StochasticSoilModelsUpdated_MapDataUpdatedAndObserverNotified() + public void GivenViewWithStochasticSoilModels_WhenStochasticSoilModelsUpdatedAndNotified_ThenMapDataUpdatedAndObserverNotified() { - // Setup + // Given using (var view = new PipingFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -701,29 +696,28 @@ var stochasticSoilModelMapData = (MapLineData) map.Data.Collection.ElementAt(stochasticSoilModelsIndex); - failureMechanism.StochasticSoilModels.AddRange(new[] - { - stochasticSoilModel - }, "path"); - var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[stochasticSoilModelsIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); - // Call + // When + failureMechanism.StochasticSoilModels.AddRange(new[] + { + stochasticSoilModel + }, "path"); failureMechanism.StochasticSoilModels.NotifyObservers(); - // Assert + // Then AssertStochasticSoilModelsMapData(failureMechanism.StochasticSoilModels, stochasticSoilModelMapData); mocks.VerifyAll(); } } [Test] - public void UpdateObserver_CalculationGroupUpdated_MapDataUpdatedAndObserverNotified() + public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new PipingFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -757,26 +751,25 @@ var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); - failureMechanism.CalculationsGroup.Children.Add(calculationB); - var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); - // Call + // When + failureMechanism.CalculationsGroup.Children.Add(calculationB); failureMechanism.CalculationsGroup.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); mocks.VerifyAll(); } } [Test] - public void UpdateObserver_CalculationInputUpdated_MapDataUpdatedAndObserverNotified() + public void GivenViewWithCalculationInputData_WhenCalculationInputUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new PipingFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -808,26 +801,25 @@ var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); - calculationA.InputParameters.SurfaceLine = surfaceLineB; - var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); - // Call + // When + calculationA.InputParameters.SurfaceLine = surfaceLineB; calculationA.InputParameters.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); mocks.VerifyAll(); } } [Test] - public void UpdateObserver_CalculationUpdated_MapDataUpdatedAndObserverNotified() + public void GivenViewWithCalculationData_WhenCalculationUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new PipingFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -859,17 +851,16 @@ var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex); - calculationA.Name = "new name"; - var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[calculationsIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); - // Call + // When + calculationA.Name = "new name"; calculationA.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); mocks.VerifyAll(); } Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs =================================================================== diff -u -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 -r69ba77aac3b14ca0060f5788121f36f5fd19c83f --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs (.../StabilityPointStructuresFailureMechanismViewTest.cs) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs (.../StabilityPointStructuresFailureMechanismViewTest.cs) (revision 69ba77aac3b14ca0060f5788121f36f5fd19c83f) @@ -297,9 +297,9 @@ } [Test] - public void UpdateObserver_AssessmentSectionUpdated_MapDataUpdated() + public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -333,19 +333,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 StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -372,11 +372,11 @@ // Precondition 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); } } @@ -428,9 +428,9 @@ } [Test] - public void UpdateObserver_ReferenceLineUpdated_MapDataUpdated() + public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -462,19 +462,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 StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -488,25 +488,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 StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -531,7 +531,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When var foreshoreProfileToUpdateFrom = new TestForeshoreProfile("originalProfile ID", new[] { new Point2D(2, 2), @@ -540,15 +540,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 StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -572,7 +572,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When failureMechanism.ForeshoreProfiles.AddRange(new[] { new TestForeshoreProfile("newProfile ID", new[] @@ -583,15 +583,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 StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -611,20 +611,20 @@ MapDataTestHelper.AssertStructuresMapData(failureMechanism.StabilityPointStructures, structuresData); - // Call + // When structure.CopyProperties(new TestStabilityPointStructure(new Point2D(1, 1), "Id")); structure.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertStructuresMapData(failureMechanism.StabilityPointStructures, structuresData); } } [Test] - public void UpdateObserver_StructuresUpdated_MapDataUpdated() + public void GivenViewWithStructuresData_WhenStructuresUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -644,21 +644,21 @@ MapDataTestHelper.AssertStructuresMapData(failureMechanism.StabilityPointStructures, structuresData); - // Call + // When failureMechanism.StabilityPointStructures.Add( new TestStabilityPointStructure(new Point2D(1, 1), "Id2")); failureMechanism.StabilityPointStructures.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertStructuresMapData(failureMechanism.StabilityPointStructures, structuresData); } } [Test] - public void UpdateObserver_CalculationGroupUpdated_MapDataUpdated() + public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -700,20 +700,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 StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -744,20 +743,19 @@ AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + // When calculationA.InputParameters.Structure = new TestStabilityPointStructure(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 StabilityPointStructuresFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -787,12 +785,11 @@ AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); + // When calculationA.Name = "new name"; - - // Call calculationA.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast>(), calculationMapData); } } Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverFailureMechanismViewTest.cs =================================================================== diff -u -rcc16af254f77623b35c173044f937cebd3e442a2 -r69ba77aac3b14ca0060f5788121f36f5fd19c83f --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverFailureMechanismViewTest.cs (.../StabilityStoneCoverFailureMechanismViewTest.cs) (revision cc16af254f77623b35c173044f937cebd3e442a2) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverFailureMechanismViewTest.cs (.../StabilityStoneCoverFailureMechanismViewTest.cs) (revision 69ba77aac3b14ca0060f5788121f36f5fd19c83f) @@ -287,9 +287,9 @@ } [Test] - public void UpdateObserver_AssessmentSectionUpdated_MapDataUpdated() + public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new StabilityStoneCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -323,19 +323,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 StabilityStoneCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -362,19 +362,19 @@ // Precondition 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); } } [Test] - public void UpdateObserver_ReferenceLineUpdated_MapDataUpdated() + public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new StabilityStoneCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -406,19 +406,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 StabilityStoneCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -432,28 +432,28 @@ 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 StabilityStoneCoverFailureMechanismView()) { - IMapControl map = ((RingtoetsMapControl)view.Controls[0]).MapControl; + IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; var failureMechanism = new StabilityStoneCoverFailureMechanism(); var failureMechanismContext = new StabilityStoneCoverFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub()); @@ -475,7 +475,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When var foreshoreProfileToUpdateFrom = new TestForeshoreProfile("originalProfile ID", new[] { new Point2D(2, 2), @@ -484,15 +484,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 StabilityStoneCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -516,7 +516,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When failureMechanism.ForeshoreProfiles.AddRange(new[] { new TestForeshoreProfile("newProfile ID", new[] @@ -527,15 +527,15 @@ }, "path"); failureMechanism.ForeshoreProfiles.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); } } [Test] - public void UpdateObserver_CalculationGroupUpdated_MapDataUpdated() + public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new StabilityStoneCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -570,22 +570,21 @@ // Precondition AssertCalculationsMapData(failureMechanism.Calculations.Cast(), - calculationMapData); + calculationMapData); + // When failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculationB); - - // Call failureMechanism.WaveConditionsCalculationGroup.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 StabilityStoneCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -612,22 +611,21 @@ // Precondition AssertCalculationsMapData(failureMechanism.Calculations.Cast(), - calculationMapData); + calculationMapData); + // When calculationA.InputParameters.ForeshoreProfile = foreshoreProfileB; - - // 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 StabilityStoneCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -653,14 +651,13 @@ // Precondition AssertCalculationsMapData(failureMechanism.Calculations.Cast(), - calculationMapData); + calculationMapData); + // When calculationA.Name = "new name"; - - // Call calculationA.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); } } Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismViewTest.cs =================================================================== diff -u -rcc16af254f77623b35c173044f937cebd3e442a2 -r69ba77aac3b14ca0060f5788121f36f5fd19c83f --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismViewTest.cs (.../WaveImpactAsphaltCoverFailureMechanismViewTest.cs) (revision cc16af254f77623b35c173044f937cebd3e442a2) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismViewTest.cs (.../WaveImpactAsphaltCoverFailureMechanismViewTest.cs) (revision 69ba77aac3b14ca0060f5788121f36f5fd19c83f) @@ -288,9 +288,9 @@ } [Test] - public void UpdateObserver_AssessmentSectionUpdated_MapDataUpdated() + public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new WaveImpactAsphaltCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -324,19 +324,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 WaveImpactAsphaltCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -363,19 +363,19 @@ // Precondition 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); } } [Test] - public void UpdateObserver_ReferenceLineUpdated_MapDataUpdated() + public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new WaveImpactAsphaltCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -407,19 +407,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 WaveImpactAsphaltCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -433,28 +433,28 @@ 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 WaveImpactAsphaltCoverFailureMechanismView()) { - IMapControl map = ((RingtoetsMapControl)view.Controls[0]).MapControl; + IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); var failureMechanismContext = new WaveImpactAsphaltCoverFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub()); @@ -476,7 +476,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When var foreshoreProfileToUpdateFrom = new TestForeshoreProfile("originalProfile ID", new[] { new Point2D(2, 2), @@ -485,15 +485,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 WaveImpactAsphaltCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -517,7 +517,7 @@ // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); - // Call + // When failureMechanism.ForeshoreProfiles.AddRange(new[] { new TestForeshoreProfile("newProfile ID", new[] @@ -528,15 +528,15 @@ }, "path"); failureMechanism.ForeshoreProfiles.NotifyObservers(); - // Assert + // Then MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); } } [Test] - public void UpdateObserver_CalculationGroupUpdated_MapDataUpdated() + public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated() { - // Setup + // Given using (var view = new WaveImpactAsphaltCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -572,20 +572,19 @@ // Precondition AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); + // When failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculationB); - - // Call failureMechanism.WaveConditionsCalculationGroup.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 WaveImpactAsphaltCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -612,20 +611,19 @@ // Precondition AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); + // When calculationA.InputParameters.ForeshoreProfile = foreshoreProfileB; - - // 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 WaveImpactAsphaltCoverFailureMechanismView()) { IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; @@ -651,12 +649,11 @@ //Precondition AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); + // When calculationA.Name = "new name"; - - // Call calculationA.NotifyObservers(); - // Assert + // Then AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData); } }