Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/Views/DuneLocationCalculationsViewBaseTest.cs =================================================================== diff -u -r664ea533634f90fcabc7ec85ee0808714936abba -rf228e12299b35a4cc8c96741362da8c1c002e2c7 --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/Views/DuneLocationCalculationsViewBaseTest.cs (.../DuneLocationCalculationsViewBaseTest.cs) (revision 664ea533634f90fcabc7ec85ee0808714936abba) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/Views/DuneLocationCalculationsViewBaseTest.cs (.../DuneLocationCalculationsViewBaseTest.cs) (revision f228e12299b35a4cc8c96741362da8c1c002e2c7) @@ -19,49 +19,181 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Linq; using System.Windows.Forms; +using Core.Common.Base; using Core.Common.Controls.Views; +using Core.Common.TestUtil; using Core.Common.Util.Reflection; +using Core.Gui.TestUtil; using NUnit.Extensions.Forms; using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Service.TestUtil; using Riskeer.DuneErosion.Data; using Riskeer.DuneErosion.Data.TestUtil; +using Riskeer.DuneErosion.Forms.GuiServices; using Riskeer.DuneErosion.Forms.Views; +using Riskeer.HydraRing.Calculation.Calculator.Factory; +using Riskeer.HydraRing.Calculation.TestUtil.Calculator; namespace Riskeer.DuneErosion.Forms.Test.Views { [TestFixture] public class DuneLocationCalculationsViewBaseTest { private const int calculateColumnIndex = 0; + private const int waterLevelColumnIndex = 6; + private const int waveHeightColumnIndex = 7; + private const int wavePeriodColumnIndex = 8; + private const int meanTidalAmplitudeColumnIndex = 9; + private const int waveDirectionalSpreadColumnIndex = 10; + private const int tideSurgePhaseDifferenceColumnIndex = 11; + private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, nameof(HydraulicBoundaryData)); + private static readonly string validHlcdFilePath = Path.Combine(testDataPath, "hlcd.sqlite"); + private static readonly string validHrdFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + private static readonly string validHrdFileVersion = "Dutch coast South19-11-2015 12:0013"; + private Form testForm; + private MockRepository mocks; [SetUp] public void Setup() { testForm = new Form(); + mocks = new MockRepository(); } [TearDown] public void TearDown() { testForm.Dispose(); + mocks.VerifyAll(); } [Test] - public void DefaultConstructor_DefaultValues() + public void Constructor_CalculationsNull_ThrowsArgumentNullException() { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + // Call - using (var view = new TestDuneLocationCalculationsView()) + void Call() => new DuneLocationCalculationsViewBase(null, + new DuneErosionFailureMechanism(), + assessmentSection, + () => 0.01, + () => "1/100"); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("calculations", exception.ParamName); + } + + [Test] + public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + void Call() => new DuneLocationCalculationsViewBase(new ObservableList(), + null, + assessmentSection, + () => 0.01, + () => "1/100"); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("failureMechanism", exception.ParamName); + } + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + void Call() => new DuneLocationCalculationsViewBase(new ObservableList(), + new DuneErosionFailureMechanism(), + null, + () => 0.01, + () => "1/100"); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void Constructor_GetTargetProbabilityFunc_ThrowsArgumentNullException() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + void Call() => new DuneLocationCalculationsViewBase(new ObservableList(), + new DuneErosionFailureMechanism(), + assessmentSection, + null, + () => "1/100"); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("getTargetProbabilityFunc", exception.ParamName); + } + + [Test] + [TestCase(null)] + [TestCase("")] + public void Constructor_GetCalculationIdentifierFuncNull_ThrowsArgumentException(string calculationIdentifier) + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + void Call() => new DuneLocationCalculationsViewBase(new ObservableList(), + new DuneErosionFailureMechanism(), + assessmentSection, + () => 0.01, + null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("getCalculationIdentifierFunc", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new DuneErosionFailureMechanism(); + + // Call + using (var view = new DuneLocationCalculationsViewBase(new ObservableList(), + failureMechanism, + assessmentSection, + () => 0.01, + () => "1/100")) { // Assert Assert.IsInstanceOf(view); Assert.IsInstanceOf(view); Assert.IsNull(view.Data); + Assert.AreSame(failureMechanism, view.FailureMechanism); + Assert.AreSame(assessmentSection, view.AssessmentSection); Assert.AreEqual(new Size(526, 85), view.AutoScrollMinSize); } @@ -71,246 +203,377 @@ public void Constructor_CalculateAllButtonCorrectlyInitialized() { // Setup & Call - TestDuneLocationCalculationsView view = ShowTestCalculatableView(); - - // Assert - var button = (Button) view.Controls.Find("CalculateForSelectedButton", true)[0]; - Assert.IsFalse(button.Enabled); + using (DuneLocationCalculationsView view = ShowDuneLocationCalculationsView()) + { + // Assert + var button = (Button) view.Controls.Find("CalculateForSelectedButton", true)[0]; + Assert.IsFalse(button.Enabled); + } } [Test] - public void OnLoad_DataGridViewCorrectlyInitialized() + public void Constructor_DataGridViewCorrectlyInitialized() { // Setup & Call - TestDuneLocationCalculationsView view = ShowTestCalculatableView(); + using (DuneLocationCalculationsView view = ShowDuneLocationCalculationsView()) + { + // Assert + var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; - // Assert - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; - Assert.AreEqual(1, dataGridView.ColumnCount); + var expectedHeaderNames = new[] + { + "Berekenen", + "Naam", + "ID", + "Coördinaten [m]", + "Kustvaknummer", + "Metrering [dam]", + "Rekenwaarde waterstand [m+NAP]", + "Rekenwaarde Hs [m]", + "Rekenwaarde Tp [s]", + "Rekenwaarde gemiddelde getijamplitude [m]", + "Rekenwaarde golfrichtingspreiding [-]", + "Rekenwaarde faseverschuiving tussen getij en opzet [uur]" + }; + DataGridViewTestHelper.AssertExpectedHeaders(expectedHeaderNames, dataGridView); - var calculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[calculateColumnIndex]; - const string expectedCalculateHeaderText = "Berekenen"; - Assert.AreEqual(expectedCalculateHeaderText, calculateColumn.HeaderText); - - var button = (Button) view.Controls.Find("CalculateForSelectedButton", true)[0]; - Assert.IsFalse(button.Enabled); + Type[] expectedColumnTypes = + { + typeof(DataGridViewCheckBoxColumn), + typeof(DataGridViewTextBoxColumn), + typeof(DataGridViewTextBoxColumn), + typeof(DataGridViewTextBoxColumn), + typeof(DataGridViewTextBoxColumn), + typeof(DataGridViewTextBoxColumn), + typeof(DataGridViewTextBoxColumn), + typeof(DataGridViewTextBoxColumn), + typeof(DataGridViewTextBoxColumn), + typeof(DataGridViewTextBoxColumn), + typeof(DataGridViewTextBoxColumn), + typeof(DataGridViewTextBoxColumn) + }; + DataGridViewTestHelper.AssertColumnTypes(expectedColumnTypes, dataGridView); + } } [Test] public void GivenFullyConfiguredView_WhenSelectingCellInRow_ThenSelectionChangedFired() { // Given - TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); + using (DuneLocationCalculationsView view = ShowFullyConfiguredDuneLocationCalculationsView()) + { + var selectionChangedCount = 0; + view.SelectionChanged += (sender, args) => selectionChangedCount++; - var createdSelection = new object(); - view.CreateForSelection = createdSelection; + var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; - var selectionChangedCount = 0; - view.SelectionChanged += (sender, args) => selectionChangedCount++; + // When + dataGridView.CurrentCell = dataGridView.Rows[1].Cells[calculateColumnIndex]; + EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0)); - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; - - // When - dataGridView.CurrentCell = dataGridView.Rows[1].Cells[calculateColumnIndex]; - EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0)); - - // Then - Assert.AreEqual(1, selectionChangedCount); + // Then + Assert.AreEqual(1, selectionChangedCount); + } } [Test] - public void Selection_Always_ReturnsCreatedSelectionObject() + public void Selection_WithoutCalculations_ReturnsNull() { - // Setup - TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); - - var createdSelection = new object(); - view.CreateForSelection = createdSelection; - // Call - object selection = view.Selection; - - // Assert - Assert.AreSame(createdSelection, selection); + using (DuneLocationCalculationsView view = ShowDuneLocationCalculationsView()) + { + // Assert + Assert.IsNull(view.Selection); + } } [Test] - public void SelectAllButton_SelectAllButtonClicked_AllCalculatableItemsSelected() + public void SelectAllButton_SelectAllButtonClicked_AllCalculationsSelected() { // Setup - TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); + using (DuneLocationCalculationsView view = ShowFullyConfiguredDuneLocationCalculationsView()) + { + var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + DataGridViewRowCollection rows = dataGridView.Rows; + var button = new ButtonTester("SelectAllButton", testForm); - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; - DataGridViewRowCollection rows = dataGridView.Rows; - var button = new ButtonTester("SelectAllButton", testForm); + // Precondition + Assert.IsFalse((bool) rows[0].Cells[calculateColumnIndex].Value); + Assert.IsFalse((bool) rows[1].Cells[calculateColumnIndex].Value); - // Precondition - Assert.IsFalse((bool) rows[0].Cells[calculateColumnIndex].Value); - Assert.IsFalse((bool) rows[1].Cells[calculateColumnIndex].Value); + // Call + button.Click(); - // Call - button.Click(); - - // Assert - Assert.IsTrue((bool) rows[0].Cells[calculateColumnIndex].Value); - Assert.IsTrue((bool) rows[1].Cells[calculateColumnIndex].Value); + // Assert + Assert.IsTrue((bool) rows[0].Cells[calculateColumnIndex].Value); + Assert.IsTrue((bool) rows[1].Cells[calculateColumnIndex].Value); + } } [Test] - public void DeselectAllButton_AllCalculatableItemsSelectedDeselectAllButtonClicked_AllCalculatableItemsNotSelected() + public void DeselectAllButton_AllCalculationsSelectedDeselectAllButtonClicked_AllCalculationsNotSelected() { // Setup - TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); - - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; - var button = new ButtonTester("DeselectAllButton", testForm); - - DataGridViewRowCollection rows = dataGridView.Rows; - foreach (DataGridViewRow row in rows) + using (DuneLocationCalculationsView view = ShowFullyConfiguredDuneLocationCalculationsView()) { - row.Cells[calculateColumnIndex].Value = true; - } + var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + var button = new ButtonTester("DeselectAllButton", testForm); - // Precondition - Assert.IsTrue((bool) rows[0].Cells[calculateColumnIndex].Value); - Assert.IsTrue((bool) rows[1].Cells[calculateColumnIndex].Value); + DataGridViewRowCollection rows = dataGridView.Rows; + foreach (DataGridViewRow row in rows) + { + row.Cells[calculateColumnIndex].Value = true; + } - // Call - button.Click(); + // Precondition + Assert.IsTrue((bool) rows[0].Cells[calculateColumnIndex].Value); + Assert.IsTrue((bool) rows[1].Cells[calculateColumnIndex].Value); - // Assert - Assert.IsFalse((bool) rows[0].Cells[calculateColumnIndex].Value); - Assert.IsFalse((bool) rows[1].Cells[calculateColumnIndex].Value); + // Call + button.Click(); + + // Assert + Assert.IsFalse((bool) rows[0].Cells[calculateColumnIndex].Value); + Assert.IsFalse((bool) rows[1].Cells[calculateColumnIndex].Value); + } } [Test] public void GivenFullyConfiguredView_WhenNoRowsSelected_ThenCalculateForSelectedButtonDisabledAndErrorMessageProvided() { // Given & When - TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); - - // Then - var button = (Button) view.Controls.Find("CalculateForSelectedButton", true)[0]; - Assert.IsFalse(button.Enabled); - var errorProvider = TypeUtils.GetField(view, "CalculateForSelectedButtonErrorProvider"); - Assert.AreEqual("Er zijn geen berekeningen geselecteerd.", errorProvider.GetError(button)); + using (DuneLocationCalculationsView view = ShowFullyConfiguredDuneLocationCalculationsView()) + { + // Then + var button = (Button) view.Controls.Find("CalculateForSelectedButton", true)[0]; + Assert.IsFalse(button.Enabled); + var errorProvider = TypeUtils.GetField(view, "CalculateForSelectedButtonErrorProvider"); + Assert.AreEqual("Er zijn geen berekeningen geselecteerd.", errorProvider.GetError(button)); + } } [Test] public void GivenFullyConfiguredView_WhenRowsSelected_ThenCalculateForSelectedButtonEnabledAndNoErrorMessageProvided() { // Given - TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + using (DuneLocationCalculationsView view = ShowFullyConfiguredDuneLocationCalculationsView()) + { + var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; - // When - dataGridView.Rows[0].Cells[calculateColumnIndex].Value = true; + // When + dataGridView.Rows[0].Cells[calculateColumnIndex].Value = true; - // Then - var button = (Button) view.Controls.Find("CalculateForSelectedButton", true)[0]; - Assert.IsTrue(button.Enabled); - var errorProvider = TypeUtils.GetField(view, "CalculateForSelectedButtonErrorProvider"); - Assert.AreEqual("", errorProvider.GetError(button)); + // Then + var button = (Button) view.Controls.Find("CalculateForSelectedButton", true)[0]; + Assert.IsTrue(button.Enabled); + var errorProvider = TypeUtils.GetField(view, "CalculateForSelectedButtonErrorProvider"); + Assert.AreEqual("", errorProvider.GetError(button)); + } } [Test] - public void CalculateForSelectedButton_OneSelected_CallsCalculateHandleCalculateSelectedObjects() + public void CalculateForSelectedButton_OneSelectedButCalculationGuiServiceNotSet_DoesNotThrowException() { // Setup - TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + using (DuneLocationCalculationsView view = ShowFullyConfiguredDuneLocationCalculationsView(assessmentSection, + new TestHydraulicBoundaryLocation())) + { + var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + DataGridViewRowCollection rows = dataGridView.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; - DataGridViewRowCollection rows = dataGridView.Rows; - rows[0].Cells[calculateColumnIndex].Value = true; + var button = new ButtonTester("CalculateForSelectedButton", testForm); - var buttonTester = new ButtonTester("CalculateForSelectedButton", testForm); + // Call + void Call() => button.Click(); - // Call - buttonTester.Click(); - - // Assert - Assert.AreEqual(1, view.ObjectsToCalculate.Count()); - TestCalculatableObject expectedObject = ((IEnumerable) view.Data).First(); - Assert.AreEqual(expectedObject, view.ObjectsToCalculate.First()); + // Assert + Assert.DoesNotThrow(Call); + } } - private TestDuneLocationCalculationsView ShowTestCalculatableView() + [Test] + public void CalculateForSelectedButton_OneCalculationSelected_CalculateForSelectedCalculationAndLogsMessages() { - var view = new TestDuneLocationCalculationsView(); + // Setup + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); - testForm.Controls.Add(view); - testForm.Show(); - return view; + var hydraulicBoundaryData = new HydraulicBoundaryData + { + HydraulicLocationConfigurationDatabase = + { + FilePath = validHlcdFilePath + }, + HydraulicBoundaryDatabases = + { + new HydraulicBoundaryDatabase + { + FilePath = validHrdFilePath, + Version = validHrdFileVersion, + Locations = + { + hydraulicBoundaryLocation + } + } + } + }; + + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(a => a.Id).Return("1"); + assessmentSection.Stub(a => a.FailureMechanismContribution).Return(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution()); + assessmentSection.Stub(a => a.HydraulicBoundaryData).Return(hydraulicBoundaryData); + assessmentSection.Stub(a => a.Attach(null)).IgnoreArguments(); + assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); + + var calculationsObserver = mocks.StrictMock(); + + var calculatorFactory = mocks.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(null)) + .IgnoreArguments() + .Return(new TestDunesBoundaryConditionsCalculator()); + mocks.ReplayAll(); + + IObservableEnumerable calculations = GenerateDuneLocationCalculations(hydraulicBoundaryLocation); + var failureMechanism = new DuneErosionFailureMechanism(); + + using (DuneLocationCalculationsView view = ShowDuneLocationCalculationsView(calculations, + failureMechanism, + assessmentSection)) + { + var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + DataGridViewRowCollection rows = dataGridView.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + calculations.Attach(calculationsObserver); + + var buttonTester = new ButtonTester("CalculateForSelectedButton", testForm); + + using (var viewParent = new TestViewParentForm()) + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + view.CalculationGuiService = new DuneLocationCalculationGuiService(viewParent); + + // Call + void Call() => buttonTester.Click(); + + // Assert + string expectedDuneLocationName = calculations.ElementAt(0).DuneLocation.Name; + + TestHelper.AssertLogMessages(Call, + messages => + { + List messageList = messages.ToList(); + + // Assert + Assert.AreEqual(8, messageList.Count); + Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{expectedDuneLocationName}' (1/100) is gestart.", messageList[0]); + CalculationServiceTestHelper.AssertValidationStartMessage(messageList[1]); + CalculationServiceTestHelper.AssertValidationEndMessage(messageList[2]); + CalculationServiceTestHelper.AssertCalculationStartMessage(messageList[3]); + Assert.AreEqual($"Hydraulische belastingenberekening voor locatie '{expectedDuneLocationName}' (1/100) is niet geconvergeerd.", messageList[4]); + StringAssert.StartsWith("Hydraulische belastingenberekening is uitgevoerd op de tijdelijke locatie", messageList[5]); + CalculationServiceTestHelper.AssertCalculationEndMessage(messageList[6]); + Assert.AreEqual($"Hydraulische belastingen berekenen voor locatie '{expectedDuneLocationName}' (1/100) is gelukt.", messageList[7]); + }); + } + } } - private TestDuneLocationCalculationsView ShowFullyConfiguredTestCalculatableView() + private DuneLocationCalculationsView ShowFullyConfiguredDuneLocationCalculationsView() { - TestDuneLocationCalculationsView view = ShowTestCalculatableView(); - view.Data = new[] + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + + var hydraulicBoundaryData = new HydraulicBoundaryData { - new TestCalculatableObject(), - new TestCalculatableObject() + HydraulicLocationConfigurationDatabase = + { + FilePath = validHlcdFilePath + }, + HydraulicBoundaryDatabases = + { + new HydraulicBoundaryDatabase + { + FilePath = validHrdFilePath, + Locations = + { + hydraulicBoundaryLocation + } + } + } }; - return view; + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryData).Return(hydraulicBoundaryData); + mocks.ReplayAll(); + + var failureMechanism = new DuneErosionFailureMechanism(); + + return ShowDuneLocationCalculationsView(GenerateDuneLocationCalculations(hydraulicBoundaryLocation), + failureMechanism, + assessmentSection); } - private class TestCalculatableRow : DuneLocationCalculationRow + private DuneLocationCalculationsView ShowFullyConfiguredDuneLocationCalculationsView(IAssessmentSection assessmentSection, + HydraulicBoundaryLocation hydraulicBoundaryLocation) { - public TestCalculatableRow(TestCalculatableObject calculatableObject) : base(calculatableObject) - { - ShouldCalculate = calculatableObject.IsChecked; - } + var failureMechanism = new DuneErosionFailureMechanism(); + + return ShowDuneLocationCalculationsView(GenerateDuneLocationCalculations(hydraulicBoundaryLocation), + failureMechanism, + assessmentSection); } - private class TestCalculatableObject : DuneLocationCalculation + private DuneLocationCalculationsView ShowDuneLocationCalculationsView() { - public TestCalculatableObject() : base(new TestDuneLocation()) {} - public bool IsChecked { get; } + return ShowDuneLocationCalculationsView(new ObservableList(), + new DuneErosionFailureMechanism(), + new AssessmentSectionStub()); } - private class TestDuneLocationCalculationsView : DuneLocationCalculationsViewBase + private DuneLocationCalculationsView ShowDuneLocationCalculationsView(IObservableEnumerable calculations, + DuneErosionFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) { - private IEnumerable data; + var view = new DuneLocationCalculationsView(calculations, + failureMechanism, + assessmentSection, + () => 0.01, + () => "1/100"); - public TestDuneLocationCalculationsView() - { - ObjectsToCalculate = new List(); - } + testForm.Controls.Add(view); + testForm.Show(); - public override object Data + return view; + } + + private static IObservableEnumerable GenerateDuneLocationCalculations(HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + return new ObservableList { - get + new DuneLocationCalculation(new DuneLocation("1", hydraulicBoundaryLocation, new DuneLocation.ConstructionProperties { - return data; - } - set + CoastalAreaId = 50, + Offset = 320 + })), + new DuneLocationCalculation(new DuneLocation("2", hydraulicBoundaryLocation, new DuneLocation.ConstructionProperties { - data = value as IEnumerable; - UpdateDataGridViewDataSource(); + CoastalAreaId = 60, + Offset = 230 + })) + { + Output = new DuneLocationCalculationOutput(CalculationConvergence.CalculatedConverged, new DuneLocationCalculationOutput.ConstructionProperties + { + WaterLevel = 1.23, + WaveHeight = 2.34, + WavePeriod = 3.45, + MeanTidalAmplitude = 4.35, + WaveDirectionalSpread = 5.54, + TideSurgePhaseDifference = 6.45 + }) } - } - - public object CreateForSelection { private get; set; } - - public IEnumerable ObjectsToCalculate { get; private set; } - - protected override object CreateSelectedItemFromCurrentRow() - { - return CreateForSelection; - } - - protected override void SetDataSource() - { - dataGridViewControl.SetDataSource(data.Select(d => new TestCalculatableRow(d)).ToArray()); - } - - protected override void CalculateForSelectedRows() - { - ObjectsToCalculate = GetCalculatableRows() - .Where(r => r.ShouldCalculate) - .Select(row => row.CalculatableObject); - } + }; } } } \ No newline at end of file