Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs =================================================================== diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -r0ce4c68a5285d7596b108dc1b42693970961bd50 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 0ce4c68a5285d7596b108dc1b42693970961bd50) @@ -35,6 +35,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Forms.GuiServices; +using Ringtoets.Integration.Data; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Views; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -64,7 +65,7 @@ public void GetViewName_Always_ReturnsViewName() { // Setup - using (var view = new DesignWaterLevelLocationsView()) + using (var view = new DesignWaterLevelLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) { // Call string viewName = info.GetViewName(view, Enumerable.Empty()); @@ -108,22 +109,43 @@ public void GetViewData_Always_ReturnsHydraulicBoundaryDatabase() { // Setup - var mocks = new MockRepository(); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - mocks.ReplayAll(); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = hydraulicBoundaryDatabase + }; var context = new DesignWaterLevelLocationsContext(assessmentSection); // Call object viewData = info.GetViewData(context); // Assert Assert.AreSame(hydraulicBoundaryDatabase.Locations, viewData); - mocks.VerifyAll(); } [Test] + public void CreateInstance_Always_SetExpectedProperties() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + }; + var context = new DesignWaterLevelLocationsContext(assessmentSection); + + using (var ringtoetsPlugin = new RingtoetsPlugin()) + { + info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(DesignWaterLevelLocationsView)); + + // Call + var view = info.CreateInstance(context) as DesignWaterLevelLocationsView; + + // Assert + Assert.AreSame(assessmentSection, view.AssessmentSection); + } + } + + [Test] [Apartment(ApartmentState.STA)] public void AfterCreate_WithGuiSet_SetsSpecificPropertiesToView() { @@ -143,7 +165,7 @@ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - using (var view = new DesignWaterLevelLocationsView()) + using (var view = new DesignWaterLevelLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) using (var ringtoetsPlugin = new RingtoetsPlugin()) { info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(DesignWaterLevelLocationsView)); @@ -164,54 +186,42 @@ public void CloseViewForData_ForMatchingAssessmentSection_ReturnsTrue() { // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - using (var view = new DesignWaterLevelLocationsView()) + using (var view = new DesignWaterLevelLocationsView(assessmentSection)) { - view.AssessmentSection = assessmentSection; - // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsTrue(closeForData); } - mocks.VerifyAll(); } [Test] public void CloseViewForData_ForNonMatchingAssessmentSection_ReturnsFalse() { // Setup - var mocks = new MockRepository(); - var assessmentSectionA = mocks.Stub(); - var assessmentSectionB = mocks.Stub(); - mocks.ReplayAll(); + var assessmentSectionA = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSectionB = new AssessmentSection(AssessmentSectionComposition.Dike); - using (var view = new DesignWaterLevelLocationsView()) + using (var view = new DesignWaterLevelLocationsView(assessmentSectionA)) { - view.AssessmentSection = assessmentSectionA; - // Call bool closeForData = info.CloseForData(view, assessmentSectionB); // Assert Assert.IsFalse(closeForData); } - mocks.VerifyAll(); } [Test] public void CloseViewForData_ForOtherObjectType_ReturnsFalse() { // Setup - var mocks = new MockRepository(); - var assessmentSectionA = mocks.Stub(); - mocks.ReplayAll(); + var assessmentSectionA = new AssessmentSection(AssessmentSectionComposition.Dike); - using (var view = new DesignWaterLevelLocationsView()) + using (var view = new DesignWaterLevelLocationsView(assessmentSectionA)) { view.Data = assessmentSectionA; @@ -221,14 +231,13 @@ // Assert Assert.IsFalse(closeForData); } - mocks.VerifyAll(); } [Test] public void CloseViewForData_ViewDataNull_ReturnsFalse() { // Setup - using (var view = new DesignWaterLevelLocationsView()) + using (var view = new DesignWaterLevelLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) { // Call bool closeForData = info.CloseForData(view, new object());