Skip to content

Commit

Permalink
Fixes #1773 Crash when simulation doesn't have results (#1774)
Browse files Browse the repository at this point in the history
* Fixes #791 Crash when simulation doesn't have results

* add a test
  • Loading branch information
rwmcintosh committed Nov 29, 2022
1 parent a2f7aad commit 5e8d31b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public override void UpdateAnalysisBasedOn(IAnalysable analysable)
{
UpdateAnalysis();
ChartEditorPresenter.SetOutputMappings(_simulation.OutputMappings);
AddRunResultToChart();
}

AddRunResultToChart();
Refresh();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public abstract class concern_for_SimulationPredictedVsObservedChartPresenter :
protected DataColumn _noDimensionDataColumn;
protected DataColumn _concentrationDataColumn;
protected DataColumn _concentrationColumnForSimulation;
protected IChartEditorPresenter _chartEditorPresenter;

protected override void Context()
{
Expand All @@ -64,6 +65,7 @@ protected override void Context()
_predictedVsObservedService = A.Fake<IPredictedVsObservedChartService>();
_chartEditorLayoutTask = A.Fake<IChartEditorLayoutTask>();
_projectRetriever = A.Fake<IProjectRetriever>();
_chartEditorPresenter = A.Fake<IChartEditorPresenter>();

_chartPresenterContext = A.Fake<ChartPresenterContext>();
A.CallTo(() => _chartPresenterContext.EditorAndDisplayPresenter).Returns(_chartEditorAndDisplayPresenter);
Expand All @@ -74,6 +76,8 @@ protected override void Context()
A.CallTo(() => _chartPresenterContext.DimensionFactory).Returns(_dimensionFactory);
A.CallTo(() => _chartPresenterContext.EditorLayoutTask).Returns(_chartEditorLayoutTask);
A.CallTo(() => _chartPresenterContext.ProjectRetriever).Returns(_projectRetriever);
A.CallTo(() => _chartPresenterContext.EditorPresenter).Returns(_chartEditorPresenter);
A.CallTo(() => _chartEditorAndDisplayPresenter.EditorPresenter).Returns(_chartEditorPresenter);

_calculationData = DomainHelperForSpecs.ObservedData();
_calculationData.Name = "calculation observed data";
Expand Down Expand Up @@ -141,6 +145,27 @@ protected override void Context()
}
}

public class When_the_simulation_does_not_have_results : concern_for_SimulationPredictedVsObservedChartPresenter
{
protected override void Context()
{
base.Context();
A.CallTo(() => _simulation.ResultsDataRepository).Returns(null);
}

protected override void Because()
{
sut.InitializeAnalysis(_predictedVsObservedChart, _simulation);
}

[Observation]
public void the_chart_editor_must_not_be_initialized_with_null()
{
A.CallTo(() => _chartEditorPresenter.AddDataRepositories(A<IEnumerable<DataRepository>>._)).MustNotHaveHappened();
}

}

public class When_the_results_have_preferred_and_non_preferred_dimensions : concern_for_SimulationPredictedVsObservedChartPresenter
{
protected override void Because()
Expand All @@ -162,5 +187,11 @@ public void adds_curve_for_concentration_column()
A.CallTo(() => _predictedVsObservedService.AddCurvesFor(A<IEnumerable<DataColumn>>._,
_concentrationDataColumn, A<PredictedVsObservedChart>._, A<Action<DataColumn, Curve>>._)).MustHaveHappened();
}

[Observation]
public void the_chart_editor_must_be_initialized_with_data_repository()
{
A.CallTo(() => _chartEditorPresenter.AddDataRepositories(A<IEnumerable<DataRepository>>.That.Contains(_calculationData))).MustHaveHappened();
}
}
}

0 comments on commit 5e8d31b

Please sign in to comment.