Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs =================================================================== diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -r0ce4c68a5285d7596b108dc1b42693970961bd50 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.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 WaveHeightLocationsView()) + using (var view = new WaveHeightLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) { // Call string viewName = info.GetViewName(view, Enumerable.Empty()); @@ -113,6 +114,7 @@ var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; mocks.ReplayAll(); + var context = new WaveHeightLocationsContext(assessmentSection); // Call @@ -124,13 +126,34 @@ } [Test] + public void CreateInstance_Always_SetExpectedProperties() + { + // Setup + + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + }; + var context = new WaveHeightLocationsContext(assessmentSection); + + using (var ringtoetsPlugin = new RingtoetsPlugin()) + { + info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(WaveHeightLocationsView)); + + // Call + var view = info.CreateInstance(context) as WaveHeightLocationsView; + + // Assert + Assert.AreSame(assessmentSection, view.AssessmentSection); + } + } + + [Test] [Apartment(ApartmentState.STA)] public void AfterCreate_WithGuiSet_SetsSpecificPropertiesToView() { // Setup var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - var guiStub = mocks.Stub(); guiStub.Stub(g => g.ProjectOpened += null).IgnoreArguments(); guiStub.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); @@ -140,11 +163,13 @@ mocks.ReplayAll(); - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + }; var context = new WaveHeightLocationsContext(assessmentSection); - using (var view = new WaveHeightLocationsView()) + using (var view = new WaveHeightLocationsView(assessmentSection)) using (var ringtoetsPlugin = new RingtoetsPlugin()) { info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(WaveHeightLocationsView)); @@ -164,54 +189,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 WaveHeightLocationsView()) + using (var view = new WaveHeightLocationsView(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 WaveHeightLocationsView()) + using (var view = new WaveHeightLocationsView(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 WaveHeightLocationsView()) + using (var view = new WaveHeightLocationsView(assessmentSectionA)) { view.Data = assessmentSectionA; @@ -221,14 +234,13 @@ // Assert Assert.IsFalse(closeForData); } - mocks.VerifyAll(); } [Test] public void CloseViewForData_ViewDataNull_ReturnsFalse() { // Setup - using (var view = new WaveHeightLocationsView()) + using (var view = new WaveHeightLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) { // Call bool closeForData = info.CloseForData(view, new object());