public void GivenCalculationWithStochasticSoilProfileAndSurfaceLine_WhenStochasticSoilProfileUpdate_ThenChartDataUpdated() { // Given MacroStabilityInwardsStochasticSoilProfile originalSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(); var calculation = new MacroStabilityInwardsCalculationScenario { InputParameters = { StochasticSoilProfile = originalSoilProfile, SurfaceLine = GetSurfaceLineWithGeometry() }, Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() }; using (new MacroStabilityInwardsCalculatorFactoryConfig()) using (var control = new MacroStabilityInwardsOutputChartControl(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { ChartDataCollection chartData = GetChartControl(control).Data; // Precondition MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, chartData); MacroStabilityInwardsStochasticSoilProfile newSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(); // When calculation.InputParameters.StochasticSoilProfile = newSoilProfile; control.UpdateChartData(); // Then MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, chartData); } }
public void GivenViewWithWaternets_WhenWaternetSetEmpty_ThenNoChartData() { // Setup MacroStabilityInwardsStochasticSoilProfile originalSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(); var calculation = new MacroStabilityInwardsCalculationScenario { InputParameters = { StochasticSoilProfile = originalSoilProfile, SurfaceLine = GetSurfaceLineWithGeometry() }, Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() }; using (new MacroStabilityInwardsCalculatorFactoryConfig()) using (var control = new MacroStabilityInwardsOutputChartControl(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { // Precondition MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, GetChartControl(control).Data); var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory)MacroStabilityInwardsCalculatorFactory.Instance; calculatorFactory.LastCreatedWaternetDailyCalculator.Output = WaternetCalculatorResultTestFactory.CreateEmptyResult(); calculatorFactory.LastCreatedWaternetExtremeCalculator.Output = WaternetCalculatorResultTestFactory.CreateEmptyResult(); // Call control.UpdateChartData(); // Assert MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyWaternetChartData(GetChartControl(control).Data); } }
public void Constructor_CalculationWithoutOutputAndWithWaternet_ChartDataEmpty() { // Setup MacroStabilityInwardsSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(); var calculation = new MacroStabilityInwardsCalculationScenario { InputParameters = { SurfaceLine = surfaceLine, StochasticSoilProfile = stochasticSoilProfile } }; // Call using (new MacroStabilityInwardsCalculatorFactoryConfig()) using (var control = new MacroStabilityInwardsOutputChartControl(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { // Assert IChartControl chartControl = GetChartControl(control); ChartDataCollection chartData = chartControl.Data; MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyChartDataWithEmptySoilLayerAndWithWaternetChartData(chartData); MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyOutputChartData(chartData); Assert.AreEqual(calculation.Name, chartControl.ChartTitle); } }
public void Constructor_CalculationWithoutStochasticSoilProfile_ChartDataSetWithDefaultSoilProfileChartDataName() { // Setup MacroStabilityInwardsSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); var calculation = new MacroStabilityInwardsCalculationScenario { InputParameters = { SurfaceLine = surfaceLine } }; // Call using (new MacroStabilityInwardsCalculatorFactoryConfig()) using (var control = new MacroStabilityInwardsOutputChartControl(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { // Assert IChartControl chartControl = GetChartControl(control); ChartDataCollection chartData = chartControl.Data; MacroStabilityInwardsViewChartDataAssert.AssertSoilProfileChartData(calculation.InputParameters.SoilProfileUnderSurfaceLine, "Ondergrondschematisatie", false, chartData.Collection.ElementAt(soilProfileIndex)); Assert.AreEqual(calculation.Name, chartControl.ChartTitle); } }
public void GivenViewWithoutOutputSet_WhenInputChangedAndObserversNotified_ThenChartDataUpdated() { // Given MacroStabilityInwardsSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(); var calculation = new MacroStabilityInwardsCalculationScenario { InputParameters = { SurfaceLine = surfaceLine, StochasticSoilProfile = stochasticSoilProfile } }; using (new MacroStabilityInwardsCalculatorFactoryConfig()) { var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory)MacroStabilityInwardsCalculatorFactory.Instance; calculatorFactory.LastCreatedWaternetDailyCalculator.Output = WaternetCalculatorResultTestFactory.CreateEmptyResult(); calculatorFactory.LastCreatedWaternetExtremeCalculator.Output = WaternetCalculatorResultTestFactory.CreateEmptyResult(); using (var form = new Form()) using (var view = new MacroStabilityInwardsOutputView(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { form.Controls.Add(view); form.Show(); MacroStabilityInwardsOutputChartControl chartControl = GetChartControl(form); ChartDataCollection chartData = GetChartControl(chartControl).Data; // Precondition MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyChartDataWithEmptySoilLayerAndEmptyWaternetChartData(chartData); // When MacroStabilityInwardsStochasticSoilProfile newSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(); calculation.InputParameters.StochasticSoilProfile = newSoilProfile; calculation.InputParameters.NotifyObservers(); // Then MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyChartDataWithEmptySoilLayerAndEmptyWaternetChartData(chartData); } } }
public void GivenViewWithWaternets_WhenObserversNotifiedAndWaternetSame_ThenChartDataNotUpdated() { // Setup MacroStabilityInwardsStochasticSoilProfile originalSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(); var calculation = new MacroStabilityInwardsCalculationScenario { InputParameters = { StochasticSoilProfile = originalSoilProfile, SurfaceLine = GetSurfaceLineWithGeometry() }, Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() }; using (new MacroStabilityInwardsCalculatorFactoryConfig()) using (var control = new MacroStabilityInwardsOutputChartControl(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { // Precondition ChartData[] chartData = GetChartControl(control).Data.Collection.ToArray(); var waternetExtremeChartDataCollection = (ChartDataCollection)chartData[waternetZonesExtremeIndex]; var waternetDailyChartDataCollection = (ChartDataCollection)chartData[waternetZonesDailyIndex]; MacroStabilityInwardsOutputViewChartDataAssert.AssertWaternetChartData(DerivedMacroStabilityInwardsInput.GetWaternetExtreme(calculation.InputParameters, new GeneralMacroStabilityInwardsInput(), RoundedDouble.NaN), waternetExtremeChartDataCollection); MacroStabilityInwardsOutputViewChartDataAssert.AssertWaternetChartData(DerivedMacroStabilityInwardsInput.GetWaternetDaily(calculation.InputParameters, new GeneralMacroStabilityInwardsInput()), waternetDailyChartDataCollection); IEnumerable <ChartData> waternetExtremeChartData = waternetExtremeChartDataCollection.Collection; IEnumerable <ChartData> waternetDailyChartData = waternetDailyChartDataCollection.Collection; // Call control.UpdateChartData(); // Assert CollectionAssert.AreEqual(waternetExtremeChartData, ((ChartDataCollection)chartData[waternetZonesExtremeIndex]).Collection); CollectionAssert.AreEqual(waternetDailyChartData, ((ChartDataCollection)chartData[waternetZonesDailyIndex]).Collection); } }
public void Constructor_CalculationWithOutput_DataSetToChartControl() { // Setup MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation()); calculation.Output = MacroStabilityInwardsOutputTestFactory.CreateOutput(); // Call using (new MacroStabilityInwardsCalculatorFactoryConfig()) using (var view = new MacroStabilityInwardsOutputView(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) using (var form = new Form()) { form.Controls.Add(view); form.Show(); MacroStabilityInwardsOutputChartControl chartControl = GetChartControl(form); // Assert Assert.AreSame(calculation, chartControl.Data); } }
public void GivenCalculationWithOutput_WhenOutputCleared_ThenChartDataUpdated() { // Given MacroStabilityInwardsSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(); var calculation = new MacroStabilityInwardsCalculationScenario { InputParameters = { SurfaceLine = surfaceLine, StochasticSoilProfile = stochasticSoilProfile }, Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() }; using (var form = new Form()) using (new MacroStabilityInwardsCalculatorFactoryConfig()) using (var view = new MacroStabilityInwardsOutputView(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { form.Controls.Add(view); form.Show(); MacroStabilityInwardsOutputChartControl chartControl = GetChartControl(form); // Precondition ChartDataCollection chartData = GetChartControl(chartControl).Data; MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, chartData); // When calculation.ClearOutput(); calculation.NotifyObservers(); // Then MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyChartDataWithEmptySoilLayerAndWithWaternetChartData(chartData); } }
public void UpdateChartData_CalculationWithoutOutputWithoutWaternet_ChartDataUpdated() { // Setup MacroStabilityInwardsSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(); var calculation = new MacroStabilityInwardsCalculationScenario { InputParameters = { SurfaceLine = surfaceLine, StochasticSoilProfile = stochasticSoilProfile }, Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() }; using (new MacroStabilityInwardsCalculatorFactoryConfig()) using (var control = new MacroStabilityInwardsOutputChartControl(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { ChartDataCollection chartData = GetChartControl(control).Data; // Precondition MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, chartData); MacroStabilityInwardsOutputViewChartDataAssert.AssertOutputChartData(calculation, chartData); calculation.ClearOutput(); // Call control.UpdateChartData(); // Assert MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyChartDataWithEmptySoilLayerAndWithWaternetChartData(chartData); MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyOutputChartData(chartData); } }
public void Constructor_ValidParameters_ExpectedValues() { // Setup var calculation = new MacroStabilityInwardsCalculationScenario(); // Call var control = new MacroStabilityInwardsOutputChartControl(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel); // Assert Assert.IsInstanceOf <UserControl>(control); Assert.IsInstanceOf <IChartView>(control); Assert.AreSame(calculation, control.Data); Assert.IsNotNull(control.Chart); Assert.AreEqual(1, control.Controls.Count); IChartControl chartControl = GetChartControl(control); Assert.IsInstanceOf <Control>(chartControl); Assert.AreEqual(DockStyle.Fill, ((Control)chartControl).Dock); Assert.AreEqual("Afstand [m]", chartControl.BottomAxisTitle); Assert.AreEqual("Hoogte [m+NAP]", chartControl.LeftAxisTitle); }
public void UpdateChartData_CalculationNameChanged_ChartTitleUpdated() { // Setup const string newCalculationName = "Test name"; var calculation = new MacroStabilityInwardsCalculationScenario(); using (var control = new MacroStabilityInwardsOutputChartControl(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { IChartControl chartControl = GetChartControl(control); // Precondition Assert.AreEqual(calculation.Name, chartControl.ChartTitle); // Call calculation.Name = newCalculationName; control.UpdateChartData(); // Assert Assert.AreEqual(newCalculationName, chartControl.ChartTitle); } }
private static IChartControl GetChartControl(MacroStabilityInwardsOutputChartControl view) { return(ControlTestHelper.GetControls <IChartControl>(view, "chartControl").Single()); }