Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs =================================================================== diff -u -r69d6acd84acd14d6739e70fad44ef155fe1e0f08 -rf0267c59b04d7626cc634fd0a1c14d9b02c061ea --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 69d6acd84acd14d6739e70fad44ef155fe1e0f08) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision f0267c59b04d7626cc634fd0a1c14d9b02c061ea) @@ -43,7 +43,7 @@ namespace Ringtoets.Integration.Forms.Test.Views { [TestFixture] - public class WaveHeightLocationsViewTest : LocationsViewSynchronizationTester + public class WaveHeightLocationsViewTest { private const int locationCalculateColumnIndex = 0; private const int includeIllustrationPointsColumnIndex = 1; @@ -52,12 +52,29 @@ private const int locationColumnIndex = 4; private const int locationWaveHeightColumnIndex = 5; + private Form testForm; + private MockRepository mockRepository; + + [SetUp] + public void Setup() + { + testForm = new Form(); + mockRepository = new MockRepository(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + mockRepository.VerifyAll(); + } + [Test] public void Constructor_ExpectedValues() { // Setup - var assessmentSection = MockRepository.Stub(); - MockRepository.ReplayAll(); + var assessmentSection = mockRepository.Stub(); + mockRepository.ReplayAll(); // Call using (var view = new WaveHeightLocationsView(assessmentSection)) @@ -72,11 +89,11 @@ public void Constructor_DataGridViewCorrectlyInitialized() { // Setup - var assessmentSection = MockRepository.Stub(); - MockRepository.ReplayAll(); + var assessmentSection = mockRepository.Stub(); + mockRepository.ReplayAll(); // Call - ShowWaveHeightLocationsView(assessmentSection, TestForm); + ShowWaveHeightLocationsView(assessmentSection, testForm); // Assert DataGridView locationsDataGridView = GetLocationsDataGridView(); @@ -100,15 +117,15 @@ var locationWaveHeightColumn = (DataGridViewTextBoxColumn) locationsDataGridView.Columns[locationWaveHeightColumnIndex]; Assert.AreEqual("Hs [m]", locationWaveHeightColumn.HeaderText); - var button = (Button) TestForm.Controls.Find("CalculateForSelectedButton", true).First(); + var button = (Button) testForm.Controls.Find("CalculateForSelectedButton", true).First(); Assert.IsFalse(button.Enabled); } [Test] public void WaveHeightLocationsView_AssessmentSectionWithData_DataGridViewCorrectlyInitialized() { // Setup & Call - ShowFullyConfiguredWaveHeightLocationsView(TestForm); + ShowFullyConfiguredWaveHeightLocationsView(testForm); // Assert DataGridViewControl locationsDataGridViewControl = GetLocationsDataGridViewControl(); @@ -165,7 +182,7 @@ public void WaveHeightLocationsView_HydraulicBoundaryDatabaseUpdated_DataGridViewCorrectlyUpdated() { // Setup - WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(TestForm); + WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(testForm); IAssessmentSection assessmentSection = view.AssessmentSection; var newHydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(10, "10", 10.0, 10.0) @@ -206,7 +223,7 @@ public void WaveHeightLocationsView_HydraulicBoundaryDatabaseUpdated_IllustrationPointsControlCorrectlyUpdated() { // Setup - WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(TestForm); + WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(testForm); IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); DataGridViewControl locationsDataGridViewControl = GetLocationsDataGridViewControl(); @@ -240,15 +257,15 @@ public void CalculateForSelectedButton_OneSelected_CallsCalculateWaveHeights(bool isSuccessful) { // Setup - WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(TestForm); + WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(testForm); IAssessmentSection assessmentSection = view.AssessmentSection; DataGridViewControl locationsDataGridViewControl = GetLocationsDataGridViewControl(); DataGridViewRowCollection rows = locationsDataGridViewControl.Rows; rows[0].Cells[locationCalculateColumnIndex].Value = true; - var guiService = MockRepository.StrictMock(); + var guiService = mockRepository.StrictMock(); - var observer = MockRepository.StrictMock(); + var observer = mockRepository.StrictMock(); assessmentSection.HydraulicBoundaryDatabase.Attach(observer); if (isSuccessful) @@ -259,10 +276,10 @@ IEnumerable locations = null; guiService.Expect(ch => ch.CalculateWaveHeights(null, null, 1, null)).IgnoreArguments().WhenCalled( invocation => { locations = (IEnumerable) invocation.Arguments[1]; }).Return(isSuccessful); - MockRepository.ReplayAll(); + mockRepository.ReplayAll(); view.CalculationGuiService = guiService; - var button = new ButtonTester("CalculateForSelectedButton", TestForm); + var button = new ButtonTester("CalculateForSelectedButton", testForm); // Call button.Click(); @@ -278,13 +295,13 @@ public void CalculateForSelectedButton_OneSelectedButCalculationGuiServiceNotSet_DoesNotThrowException() { // Setup - ShowFullyConfiguredWaveHeightLocationsView(TestForm); + ShowFullyConfiguredWaveHeightLocationsView(testForm); DataGridViewControl locationsDataGridViewControl = GetLocationsDataGridViewControl(); DataGridViewRowCollection rows = locationsDataGridViewControl.Rows; rows[0].Cells[locationCalculateColumnIndex].Value = true; - var button = new ButtonTester("CalculateForSelectedButton", TestForm); + var button = new ButtonTester("CalculateForSelectedButton", testForm); // Call TestDelegate test = () => button.Click(); @@ -293,6 +310,21 @@ Assert.DoesNotThrow(test); } + private DataGridView GetLocationsDataGridView() + { + return ControlTestHelper.GetDataGridView(testForm, "DataGridView"); + } + + private DataGridViewControl GetLocationsDataGridViewControl() + { + return ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); + } + + private IllustrationPointsControl GetIllustrationPointsControl() + { + return ControlTestHelper.GetControls(testForm, "IllustrationPointsControl").Single(); + } + private static IEnumerable CreateControlItems( GeneralResult generalResult) { @@ -388,61 +420,61 @@ } } - #region LocationsViewSynchronizationTester implementation - - protected override int OutputColumnIndex + [TestFixture] + public class WaveHeightLocationsViewSynchronizationTest : LocationsViewSynchronizationTester { - get + protected override int OutputColumnIndex { - return locationWaveHeightColumnIndex; + get + { + return locationWaveHeightColumnIndex; + } } - } - protected override object GetLocationSelection(LocationsView view, object selectedRowObject) - { - IAssessmentSection assessmentSection = view.AssessmentSection; + protected override object GetLocationSelection(LocationsView view, object selectedRowObject) + { + IAssessmentSection assessmentSection = view.AssessmentSection; - return new WaveHeightLocationContext(assessmentSection.HydraulicBoundaryDatabase, - ((HydraulicBoundaryLocationRow) selectedRowObject).CalculatableObject); - } + return new WaveHeightLocationContext(assessmentSection.HydraulicBoundaryDatabase, + ((HydraulicBoundaryLocationRow) selectedRowObject).CalculatableObject); + } - protected override LocationsView ShowFullyConfiguredLocationsView(Form form) - { - return ShowFullyConfiguredWaveHeightLocationsView(form); - } + protected override LocationsView ShowFullyConfiguredLocationsView(Form form) + { + return ShowFullyConfiguredWaveHeightLocationsView(form); + } - protected override void ReplaceHydraulicBoundaryDatabaseAndNotifyObservers(LocationsView view) - { - IAssessmentSection assessmentSection = view.AssessmentSection; - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(10, "10", 10.0, 10.0); - - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + protected override void ReplaceHydraulicBoundaryDatabaseAndNotifyObservers(LocationsView view) { - Locations = + IAssessmentSection assessmentSection = view.AssessmentSection; + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(10, "10", 10.0, 10.0); + + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - hydraulicBoundaryLocation - } - }; + Locations = + { + hydraulicBoundaryLocation + } + }; - assessmentSection.NotifyObservers(); - } + assessmentSection.NotifyObservers(); + } - protected override void ClearLocationOutputAndNotifyObservers(LocationsView view) - { - IAssessmentSection assessmentSection = view.AssessmentSection; + protected override void ClearLocationOutputAndNotifyObservers(LocationsView view) + { + IAssessmentSection assessmentSection = view.AssessmentSection; - assessmentSection.HydraulicBoundaryDatabase.Locations.ForEach(loc => loc.WaveHeightCalculation.Output = null); - assessmentSection.NotifyObservers(); - } + assessmentSection.HydraulicBoundaryDatabase.Locations.ForEach(loc => loc.WaveHeightCalculation.Output = null); + assessmentSection.NotifyObservers(); + } - protected override void AddLocationOutputAndNotifyObservers(LocationsView view) - { - IAssessmentSection assessmentSection = view.AssessmentSection; + protected override void AddLocationOutputAndNotifyObservers(LocationsView view) + { + IAssessmentSection assessmentSection = view.AssessmentSection; - assessmentSection.HydraulicBoundaryDatabase.Locations.First().WaveHeightCalculation.Output = new TestHydraulicBoundaryLocationOutput(new TestGeneralResultSubMechanismIllustrationPoint()); - assessmentSection.NotifyObservers(); + assessmentSection.HydraulicBoundaryDatabase.Locations.First().WaveHeightCalculation.Output = new TestHydraulicBoundaryLocationOutput(new TestGeneralResultSubMechanismIllustrationPoint()); + assessmentSection.NotifyObservers(); + } } - - #endregion } } \ No newline at end of file