Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs =================================================================== diff -u -r870f565685404ea85a8b54b6c863e3821929031a -r68a504ed77ed5a98c8023539f140b8a36d7de768 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 870f565685404ea85a8b54b6c863e3821929031a) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 68a504ed77ed5a98c8023539f140b8a36d7de768) @@ -40,7 +40,7 @@ [TestFixture] public class HydraulicBoundaryLocationsViewTest { - private const int locationCalculateColumnIndex = 0; + private const int calculateColumnIndex = 0; private const int includeIllustrationPointsColumnIndex = 1; private const int locationNameColumnIndex = 2; private const int locationIdColumnIndex = 3; @@ -60,37 +60,22 @@ } [Test] - public void Constructor_LocationsNull_ThrowsArgumentNullException() + public void Constructor_CalculationsNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => new TestHydraulicBoundaryLocationsView(null, - hbl => new HydraulicBoundaryLocationCalculation(hbl), new ObservableTestAssessmentSectionStub()); // Assert var exception = Assert.Throws(call); - Assert.AreEqual("locations", exception.ParamName); + Assert.AreEqual("calculations", exception.ParamName); } [Test] - public void Constructor_GetCalculationFuncNull_ThrowsArgumentNullException() - { - // Call - TestDelegate call = () => new TestHydraulicBoundaryLocationsView(new ObservableList(), - null, - new ObservableTestAssessmentSectionStub()); - - // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("getCalculationFunc", exception.ParamName); - } - - [Test] public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => new TestHydraulicBoundaryLocationsView(new ObservableList(), - hbl => new HydraulicBoundaryLocationCalculation(hbl), + TestDelegate call = () => new TestHydraulicBoundaryLocationsView(new ObservableList(), null); // Assert @@ -105,7 +90,7 @@ TestHydraulicBoundaryLocationsView view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); // Assert - Assert.IsInstanceOf>(view); + Assert.IsInstanceOf>(view); Assert.IsNull(view.Data); } @@ -119,8 +104,8 @@ DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "dataGridView"); Assert.AreEqual(5, dataGridView.ColumnCount); - var locationCalculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[locationCalculateColumnIndex]; - Assert.AreEqual("Berekenen", locationCalculateColumn.HeaderText); + var calculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[calculateColumnIndex]; + Assert.AreEqual("Berekenen", calculateColumn.HeaderText); var includeIllustrationPointsColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[includeIllustrationPointsColumnIndex]; Assert.AreEqual("Illustratiepunten inlezen", includeIllustrationPointsColumn.HeaderText); @@ -151,23 +136,23 @@ DataGridViewCellCollection cells = rows[0].Cells; Assert.AreEqual(5, cells.Count); - Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); Assert.AreEqual(false, cells[includeIllustrationPointsColumnIndex].FormattedValue); Assert.AreEqual("1", cells[locationNameColumnIndex].FormattedValue); Assert.AreEqual("1", cells[locationIdColumnIndex].FormattedValue); Assert.AreEqual(new Point2D(1, 1).ToString(), cells[locationColumnIndex].FormattedValue); cells = rows[1].Cells; Assert.AreEqual(5, cells.Count); - Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); Assert.AreEqual(false, cells[includeIllustrationPointsColumnIndex].FormattedValue); Assert.AreEqual("2", cells[locationNameColumnIndex].FormattedValue); Assert.AreEqual("2", cells[locationIdColumnIndex].FormattedValue); Assert.AreEqual(new Point2D(2, 2).ToString(), cells[locationColumnIndex].FormattedValue); cells = rows[2].Cells; Assert.AreEqual(5, cells.Count); - Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); + Assert.AreEqual(false, cells[calculateColumnIndex].FormattedValue); Assert.AreEqual(true, cells[includeIllustrationPointsColumnIndex].FormattedValue); Assert.AreEqual("3", cells[locationNameColumnIndex].FormattedValue); Assert.AreEqual("3", cells[locationIdColumnIndex].FormattedValue); @@ -182,7 +167,7 @@ DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "dataGridView"); DataGridViewRowCollection rows = dataGridView.Rows; - rows[0].Cells[locationCalculateColumnIndex].Value = true; + rows[0].Cells[calculateColumnIndex].Value = true; var button = new ButtonTester("CalculateForSelectedButton", testForm); @@ -197,12 +182,6 @@ public void GetIllustrationPointControlItems_ViewWithData_ReturnsExpectedControlItems() { // Setup - var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); - var locations = new ObservableList - { - hydraulicBoundaryLocation - }; - var topLevelIllustrationPoints = new[] { new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), @@ -213,27 +192,22 @@ var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints); var output = new TestHydraulicBoundaryLocationOutput(generalResult); - var calculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation) + var calculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()) { Output = output }; - - HydraulicBoundaryLocation getCalculationsCallArgument = null; - - TestHydraulicBoundaryLocationsView view = ShowTestHydraulicBoundaryLocationsView(locations, hbl => + var calculations = new ObservableList { - getCalculationsCallArgument = hbl; + calculation + }; - return calculation; - }); + TestHydraulicBoundaryLocationsView view = ShowTestHydraulicBoundaryLocationsView(calculations); // Call IEnumerable actualControlItems = view.PublicGetIllustrationPointControlItems(); // Assert - Assert.AreSame(hydraulicBoundaryLocation, getCalculationsCallArgument); - IEnumerable expectedControlItems = CreateControlItems(generalResult); CollectionAssert.AreEqual(expectedControlItems, actualControlItems, @@ -257,16 +231,12 @@ private void ShowTestHydraulicBoundaryLocationsView() { - ShowTestHydraulicBoundaryLocationsView(new ObservableList(), - hbl => new HydraulicBoundaryLocationCalculation(hbl)); + ShowTestHydraulicBoundaryLocationsView(new ObservableList()); } - private TestHydraulicBoundaryLocationsView ShowTestHydraulicBoundaryLocationsView(ObservableList locations, - Func getCalculationFunc) + private TestHydraulicBoundaryLocationsView ShowTestHydraulicBoundaryLocationsView(ObservableList calculations) { - var view = new TestHydraulicBoundaryLocationsView(locations, - getCalculationFunc, - new ObservableTestAssessmentSectionStub()); + var view = new TestHydraulicBoundaryLocationsView(calculations, new ObservableTestAssessmentSectionStub()); testForm.Controls.Add(view); testForm.Show(); @@ -276,50 +246,35 @@ private TestHydraulicBoundaryLocationsView ShowFullyConfiguredTestHydraulicBoundaryLocationsView() { - var locations = new ObservableList(); - - locations.AddRange(new[] + return ShowTestHydraulicBoundaryLocationsView(new ObservableList { - new HydraulicBoundaryLocation(1, "1", 1.0, 1.0), - new HydraulicBoundaryLocation(2, "2", 2.0, 2.0), - new HydraulicBoundaryLocation(3, "3", 3.0, 3.0) - }); - - var calculations = new[] - { - new HydraulicBoundaryLocationCalculation(locations[0]), - new HydraulicBoundaryLocationCalculation(locations[1]) + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(1, "1", 1.0, 1.0)), + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(2, "2", 2.0, 2.0)) { Output = new TestHydraulicBoundaryLocationOutput(1.23) }, - new HydraulicBoundaryLocationCalculation(locations[2]) + new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(3, "3", 3.0, 3.0)) { InputParameters = { ShouldIllustrationPointsBeCalculated = true } } - }; - - return ShowTestHydraulicBoundaryLocationsView(locations, - hbl => calculations[locations.IndexOf(hbl)]); + }); } private sealed class TestHydraulicBoundaryLocationsView : HydraulicBoundaryLocationsView { - public TestHydraulicBoundaryLocationsView(ObservableList locations, - Func getCalculationFunc, + public TestHydraulicBoundaryLocationsView(ObservableList calculations, IAssessmentSection assessmentSection) - : base(locations, - getCalculationFunc, - assessmentSection) {} + : base(calculations, assessmentSection) {} public IEnumerable PublicGetIllustrationPointControlItems() { return GetIllustrationPointControlItems(); } - protected override void HandleCalculateSelectedLocations(IEnumerable locations) + protected override void PerformSelectedCalculations(IEnumerable calculations) { throw new NotImplementedException(); }