diff --git a/src/PKSim.Presentation/Presenters/Simulations/ConfigureSimulationPresenter.cs b/src/PKSim.Presentation/Presenters/Simulations/ConfigureSimulationPresenter.cs index 7cb97f757..ef3a37303 100644 --- a/src/PKSim.Presentation/Presenters/Simulations/ConfigureSimulationPresenter.cs +++ b/src/PKSim.Presentation/Presenters/Simulations/ConfigureSimulationPresenter.cs @@ -35,10 +35,12 @@ public interface IConfigureSimulationPresenter : ISimulationWizardPresenter public class ConfigureSimulationPresenter : ConfigureSimulationPresenterBase { - public ConfigureSimulationPresenter(IConfigureSimulationView view, ISubPresenterItemManager subPresenterItemManager, ISimulationModelCreator simulationModelCreator, + public ConfigureSimulationPresenter(IConfigureSimulationView view, ISubPresenterItemManager subPresenterItemManager, + ISimulationModelCreator simulationModelCreator, IHeavyWorkManager heavyWorkManager, ICloner cloner, IDialogCreator dialogCreator, ISimulationParametersUpdater simulationParametersUpdater, IFullPathDisplayResolver fullPathDisplayResolver, IBuildingBlockInSimulationSynchronizer buildingBlockInSimulationSynchronizer) - : base(view, subPresenterItemManager, simulationModelCreator, heavyWorkManager, cloner, dialogCreator, simulationParametersUpdater, fullPathDisplayResolver, buildingBlockInSimulationSynchronizer, CreationMode.Configure) + : base(view, subPresenterItemManager, simulationModelCreator, heavyWorkManager, cloner, dialogCreator, simulationParametersUpdater, + fullPathDisplayResolver, buildingBlockInSimulationSynchronizer, CreationMode.Configure) { } @@ -50,7 +52,8 @@ protected override string ViewCaption(Simulation simulation) } } - public abstract class ConfigureSimulationPresenterBase : SimulationWizardPresenter, IConfigureSimulationPresenter where TSimulationView : ISimulationWizardView + public abstract class ConfigureSimulationPresenterBase : SimulationWizardPresenter, IConfigureSimulationPresenter + where TSimulationView : ISimulationWizardView { private readonly ICloner _cloner; private readonly ISimulationParametersUpdater _simulationParametersUpdater; @@ -63,13 +66,13 @@ public abstract class ConfigureSimulationPresenterBase : Simula protected ConfigureSimulationPresenterBase( TSimulationView view, ISubPresenterItemManager subPresenterItemManager, - ISimulationModelCreator simulationModelCreator, + ISimulationModelCreator simulationModelCreator, IHeavyWorkManager heavyWorkManager, - ICloner cloner, - IDialogCreator dialogCreator, - ISimulationParametersUpdater simulationParametersUpdater, - IFullPathDisplayResolver fullPathDisplayResolver, - IBuildingBlockInSimulationSynchronizer buildingBlockInSimulationSynchronizer, + ICloner cloner, + IDialogCreator dialogCreator, + ISimulationParametersUpdater simulationParametersUpdater, + IFullPathDisplayResolver fullPathDisplayResolver, + IBuildingBlockInSimulationSynchronizer buildingBlockInSimulationSynchronizer, CreationMode creationMode) : base(view, subPresenterItemManager, simulationModelCreator, heavyWorkManager, dialogCreator) { @@ -105,11 +108,13 @@ public IPKSimCommand ConfigureSimulationWithBuildingBlock(Simulation simulation, break; case PKSimBuildingBlockType.Formulation: itemToActivate = SimulationItems.CompoundProtocols; - updateAction = () => PresenterAt(SimulationItems.CompoundProtocols).UpdateSelectedFormulation(templateBuildingBlock.DowncastTo()); + updateAction = () => + PresenterAt(SimulationItems.CompoundProtocols).UpdateSelectedFormulation(templateBuildingBlock.DowncastTo()); break; case PKSimBuildingBlockType.Protocol: itemToActivate = SimulationItems.CompoundProtocols; - updateAction = () => PresenterAt(SimulationItems.CompoundProtocols).UpdateSelectedProtocol(templateBuildingBlock.DowncastTo()); + updateAction = () => + PresenterAt(SimulationItems.CompoundProtocols).UpdateSelectedProtocol(templateBuildingBlock.DowncastTo()); break; case PKSimBuildingBlockType.Event: break; @@ -160,16 +165,11 @@ protected override void UpdateSimulationProperties() _simulationModelCreator.CreateModelFor(Simulation); - //After the simulation was created, we can update the output mapping (we need the model to be available in the simulation) - //to make sure we swap out the simulation references - _originalSimulation.OutputMappings.Each(x => Simulation.OutputMappings.Add(x.Clone())); - Simulation.OutputMappings.SwapSimulation(_originalSimulation, Simulation); - - //now update all parameters from the original simulationToClone + //now update all parameters from the _originalSimulation var validationResult = _simulationParametersUpdater.ReconciliateSimulationParametersBetween(_originalSimulation, Simulation); displayMissingParametersMessage(validationResult); - //last update the version of the new simulationToClone + //last update the version of the new Simulation Simulation.Version++; Simulation.StructureVersion++; } diff --git a/tests/PKSim.Tests/Presentation/ConfigureSimulationPresenterSpecs.cs b/tests/PKSim.Tests/Presentation/ConfigureSimulationPresenterSpecs.cs index d358bd35c..8e0537549 100644 --- a/tests/PKSim.Tests/Presentation/ConfigureSimulationPresenterSpecs.cs +++ b/tests/PKSim.Tests/Presentation/ConfigureSimulationPresenterSpecs.cs @@ -1,5 +1,4 @@ -using System.Linq; -using FakeItEasy; +using FakeItEasy; using OSPSuite.BDDHelper; using OSPSuite.BDDHelper.Extensions; using OSPSuite.Core.Domain; @@ -54,7 +53,8 @@ protected override void Context() _simulationCompoundProcessesPresenter = _subPresenterManager.CreateFake(SimulationItems.CompoundsProcesses); _simulationEventsPresenter = _subPresenterManager.CreateFake(SimulationItems.Events); - sut = new ConfigureSimulationPresenter(_view, _subPresenterManager, _simulationModelCreator, _heavyWorkManager, _cloner, _dialogCreator, _simulationParametersUpdater, _fullPathDisplayResolver, _buildingBlockInSimulationSynchronizer); + sut = new ConfigureSimulationPresenter(_view, _subPresenterManager, _simulationModelCreator, _heavyWorkManager, _cloner, _dialogCreator, + _simulationParametersUpdater, _fullPathDisplayResolver, _buildingBlockInSimulationSynchronizer); _originalSimulation = A.Fake(); _clonedSimulation = A.Fake(); @@ -126,14 +126,14 @@ public void should_save_the_configuration_defined_by_the_user() [Observation] public void should_update_the_parameters_from_the_original_simulation() { - A.CallTo(() => _simulationParametersUpdater.ReconciliateSimulationParametersBetween(_originalSimulation, _clonedSimulation, PKSimBuildingBlockType.Simulation)).MustHaveHappened(); + A.CallTo(() => _simulationParametersUpdater.ReconciliateSimulationParametersBetween(_originalSimulation, _clonedSimulation, + PKSimBuildingBlockType.Simulation)).MustHaveHappened(); } [Observation] public void should_have_updated_the_output_mapping_based_on_the_original_simulation() { - _clonedSimulation.OutputMappings.Count().ShouldBeEqualTo(1); - _clonedSimulation.OutputMappings.ElementAt(0).Simulation.ShouldBeEqualTo(_clonedSimulation); + _clonedSimulation.OutputMappings.ShouldBeEmpty(); } } @@ -165,7 +165,9 @@ protected override void Because() public void should_display_a_warning_to_the_user_with_the_name_of_the_full_path_of_all_parameters_that_will_not_be_used_anymore() { _message.Contains(_fullPathForParameter).ShouldBeTrue(); - _message.Contains("These parameters were changed by the user. Because of a simulation reconfiguration, they will not be used for this simulation").ShouldBeTrue(); + _message.Contains( + "These parameters were changed by the user. Because of a simulation reconfiguration, they will not be used for this simulation") + .ShouldBeTrue(); } } } \ No newline at end of file