Skip to content

Commit

Permalink
2592 solved (#2628)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeDaskalakis authored May 17, 2023
1 parent f4c5dc6 commit ea6b9aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ public interface IConfigureSimulationPresenter : ISimulationWizardPresenter

public class ConfigureSimulationPresenter : ConfigureSimulationPresenterBase<IConfigureSimulationView>
{
public ConfigureSimulationPresenter(IConfigureSimulationView view, ISubPresenterItemManager<ISimulationItemPresenter> subPresenterItemManager, ISimulationModelCreator simulationModelCreator,
public ConfigureSimulationPresenter(IConfigureSimulationView view, ISubPresenterItemManager<ISimulationItemPresenter> 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)
{
}

Expand All @@ -50,7 +52,8 @@ protected override string ViewCaption(Simulation simulation)
}
}

public abstract class ConfigureSimulationPresenterBase<TSimulationView> : SimulationWizardPresenter<TSimulationView>, IConfigureSimulationPresenter where TSimulationView : ISimulationWizardView
public abstract class ConfigureSimulationPresenterBase<TSimulationView> : SimulationWizardPresenter<TSimulationView>, IConfigureSimulationPresenter
where TSimulationView : ISimulationWizardView
{
private readonly ICloner _cloner;
private readonly ISimulationParametersUpdater _simulationParametersUpdater;
Expand All @@ -63,13 +66,13 @@ public abstract class ConfigureSimulationPresenterBase<TSimulationView> : Simula
protected ConfigureSimulationPresenterBase(
TSimulationView view,
ISubPresenterItemManager<ISimulationItemPresenter> 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)
{
Expand Down Expand Up @@ -105,11 +108,13 @@ public IPKSimCommand ConfigureSimulationWithBuildingBlock(Simulation simulation,
break;
case PKSimBuildingBlockType.Formulation:
itemToActivate = SimulationItems.CompoundProtocols;
updateAction = () => PresenterAt(SimulationItems.CompoundProtocols).UpdateSelectedFormulation(templateBuildingBlock.DowncastTo<Formulation>());
updateAction = () =>
PresenterAt(SimulationItems.CompoundProtocols).UpdateSelectedFormulation(templateBuildingBlock.DowncastTo<Formulation>());
break;
case PKSimBuildingBlockType.Protocol:
itemToActivate = SimulationItems.CompoundProtocols;
updateAction = () => PresenterAt(SimulationItems.CompoundProtocols).UpdateSelectedProtocol(templateBuildingBlock.DowncastTo<Protocol>());
updateAction = () =>
PresenterAt(SimulationItems.CompoundProtocols).UpdateSelectedProtocol(templateBuildingBlock.DowncastTo<Protocol>());
break;
case PKSimBuildingBlockType.Event:
break;
Expand Down Expand Up @@ -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++;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using FakeItEasy;
using FakeItEasy;
using OSPSuite.BDDHelper;
using OSPSuite.BDDHelper.Extensions;
using OSPSuite.Core.Domain;
Expand Down Expand Up @@ -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<Simulation>();
_clonedSimulation = A.Fake<Simulation>();
Expand Down Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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();
}
}
}

0 comments on commit ea6b9aa

Please sign in to comment.