-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1691 initialize on batch create (#1694)
* wip * Fixes #1691 Clone simulation on batch creation * Fixes #1691 Clone simulation on batch creation * Fixes #1691 Clone simulation on batch creation * Fixes #1691 Clone simulation on batch creation
- Loading branch information
1 parent
1a9e634
commit adf6f9f
Showing
8 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using OSPSuite.Core.Domain; | ||
using OSPSuite.Core.Domain.Builder; | ||
using OSPSuite.Core.Domain.Services; | ||
using OSPSuite.R.Domain; | ||
|
||
namespace OSPSuite.R.Services | ||
{ | ||
public interface ISimulationTask | ||
{ | ||
IModelCoreSimulation Clone(IModelCoreSimulation simulation); | ||
} | ||
public class SimulationTask : ISimulationTask | ||
{ | ||
private readonly ICloneManagerForModel _cloneManagerForModel; | ||
|
||
public SimulationTask(ICloneManagerForModel cloneManagerForModel) | ||
{ | ||
_cloneManagerForModel = cloneManagerForModel; | ||
} | ||
public IModelCoreSimulation Clone(IModelCoreSimulation simulationToClone) | ||
{ | ||
var simulation = new ModelCoreSimulation | ||
{ | ||
Model = _cloneManagerForModel.CloneModel(simulationToClone.Model) | ||
}; | ||
|
||
// Initialize a BuildConfiguration with only SimulationSettings because some of the properties to complete the initialization are required | ||
// None of the other properties are required to complete the simulation | ||
var simulationBuildConfiguration = new BuildConfiguration | ||
{ | ||
SimulationSettings = _cloneManagerForModel.Clone(simulationToClone.SimulationSettings) | ||
}; | ||
simulation.BuildConfiguration = simulationBuildConfiguration; | ||
|
||
return simulation; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
tests/OSPSuite.R.Tests/Domain/ConcurrentRunSimulationBatchSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using OSPSuite.BDDHelper; | ||
using OSPSuite.BDDHelper.Extensions; | ||
using OSPSuite.R.Services; | ||
|
||
namespace OSPSuite.R.Domain | ||
{ | ||
public class concern_for_ConcurrentRunSimulationBatch : ContextForIntegration<ConcurrentRunSimulationBatch> | ||
{ | ||
protected ISimulationPersister _simulationPersister; | ||
|
||
public override void GlobalContext() | ||
{ | ||
base.GlobalContext(); | ||
_simulationPersister = Api.GetSimulationPersister(); | ||
} | ||
} | ||
|
||
public class When_creating_a_new_simulation_batch : concern_for_ConcurrentRunSimulationBatch | ||
{ | ||
private Simulation _simulation; | ||
|
||
|
||
protected override void Context() | ||
{ | ||
base.Context(); | ||
_simulation = _simulationPersister.LoadSimulation(HelperForSpecs.DataFile("S1.pkml")); | ||
} | ||
|
||
protected override void Because() | ||
{ | ||
sut = new ConcurrentRunSimulationBatch | ||
( | ||
_simulation, | ||
new SimulationBatchOptions() | ||
); | ||
} | ||
|
||
[Observation] | ||
public void should_not_be_reference_to_the_original_simulation() | ||
{ | ||
sut.Simulation.ShouldNotBeEqualTo(_simulation); | ||
} | ||
} | ||
} |