public void Constructor_ValidParameters_ExpectedValues() { // Setup var calculation = new MacroStabilityInwardsCalculationScenario(); // Call using (var view = new MacroStabilityInwardsOutputView(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { // Assert Assert.IsInstanceOf <UserControl>(view); Assert.IsInstanceOf <IChartView>(view); Assert.AreSame(calculation, view.Data); Assert.IsNotNull(view.Chart); Assert.AreEqual(1, view.Controls.Count); var splitContainer = view.Controls[0] as SplitContainer; Assert.IsNotNull(splitContainer); Assert.AreEqual(1, splitContainer.Panel1.Controls.Count); Assert.AreEqual(1, splitContainer.Panel2.Controls.Count); Assert.IsInstanceOf <MacroStabilityInwardsOutputChartControl>(splitContainer.Panel1.Controls[0]); Assert.IsInstanceOf <MacroStabilityInwardsSlicesTable>(splitContainer.Panel2.Controls[0]); } }
public void GivenViewWithOutputSet_WhenOutputCleared_ThenTableCleared() { // Given var calculation = new MacroStabilityInwardsCalculationScenario { Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() }; using (var view = new MacroStabilityInwardsOutputView(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel)) { MacroStabilityInwardsSlicesTable slicesTable = GetSlicesTable(view); // Precondition Assert.AreEqual(3, slicesTable.Rows.Count); // When calculation.ClearOutput(); calculation.NotifyObservers(); // Then Assert.AreEqual(0, slicesTable.Rows.Count); } }
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 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); } }
private static MacroStabilityInwardsSlicesTable GetSlicesTable(MacroStabilityInwardsOutputView view) { return(ControlTestHelper.GetControls <MacroStabilityInwardsSlicesTable>(view, "slicesTable").Single()); }