Skip to content

Commit

Permalink
1749 default scaling when changing output
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeDaskalakis committed Nov 8, 2022
1 parent 5f12a7d commit 584d5ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using OSPSuite.Core.Domain.Repositories;
using OSPSuite.Core.Domain.Services;
using OSPSuite.Core.Events;
using OSPSuite.Core.Services;
using OSPSuite.Presentation.DTO;
using OSPSuite.Presentation.Mappers;
using OSPSuite.Presentation.Views;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class SimulationOutputMappingPresenter : AbstractSubPresenter<ISimulation
private readonly ISimulationOutputMappingToOutputMappingDTOMapper _outputMappingDTOMapper;
private readonly IQuantityToSimulationQuantitySelectionDTOMapper _simulationQuantitySelectionDTOMapper;
private readonly List<SimulationQuantitySelectionDTO> _allAvailableOutputs = new List<SimulationQuantitySelectionDTO>();
private readonly IOutputMappingMatchingTask _outputMappingMatchingTask;

private readonly NotifyList<SimulationOutputMappingDTO> _listOfOutputMappingDTOs;

Expand All @@ -64,6 +66,7 @@ public SimulationOutputMappingPresenter(
_observedDataRepository = observedDataRepository;
_outputMappingDTOMapper = outputMappingDTOMapper;
_simulationQuantitySelectionDTOMapper = simulationQuantitySelectionDTOMapper;
_outputMappingMatchingTask = new OutputMappingMatchingTask(_entitiesInSimulationRetriever);
_listOfOutputMappingDTOs = new NotifyList<SimulationOutputMappingDTO>();
}

Expand Down Expand Up @@ -149,6 +152,7 @@ public void UpdateSimulationOutputMappings(SimulationOutputMappingDTO simulation
MarkSimulationAsChanged();
if (!_simulation.OutputMappings.OutputMappingsUsingDataRepository(simulationOutputMappingDTO.ObservedData).Any())
_simulation.OutputMappings.Add(simulationOutputMappingDTO.Mapping);
simulationOutputMappingDTO.Scaling = _outputMappingMatchingTask.DefaultScalingFor(simulationOutputMappingDTO.Output.Quantity);
}

public void MarkSimulationAsChanged()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,21 @@ public void should_have_removed_the_corresponding_output_mapping()
}
}

public class When_new_output_gets_mapped : concern_for_SimulationOutputMappingPresenter
{
protected override void Context()
{
base.Context();
_simulation1.OutputMappings.Add(_outputMapping1);
_simulation1.OutputMappings.All[0].Scaling = Scalings.Linear;
sut.SetSimulation(_simulation1);
sut.UpdateSimulationOutputMappings(_outputMappingDTO1);
}

[Observation]
public void should_have_removed_the_corresponding_output_mapping()
{
_simulation1.OutputMappings.All[0].Scaling.ShouldBeEqualTo(Scalings.Log);
}
}
}

0 comments on commit 584d5ab

Please sign in to comment.