protected override void Context() { base.Context(); _simulationRunResults = new SimulationRunResults(true, Enumerable.Empty <SolverWarning>(), DomainHelperForSpecs.IndividualSimulationDataRepositoryFor("Sim")); _simulation = new ModelCoreSimulation(); A.CallTo(_simModelManager).WithReturnType <SimulationRunResults>().Returns(_simulationRunResults); }
protected override void Because() { var task = Task.Run(() => sut.RunSimulation(_simulation)); //needs to sleep so that the action actually starts Thread.Sleep(100); sut.StopSimulation(); _runResults = task.Result; }
private void copyResultsToSimulation(SimulationRunResults results, IMoBiSimulation simulation) { var resultsResults = results.Results; if (simulation.Results != null) { simulation.HistoricResults.Add(simulation.Results); } setMolecularWeight(simulation, resultsResults); simulation.Results = resultsResults; }
private void showWarningsIfAny(SimulationRunResults results) { if (!results.Warnings.Any()) { return; } using (var presenter = _applicationController.Start <ISolverMessagePresenter>()) { presenter.Show(results.Warnings); } }
private IInfoCommand getSimulationResultLabel(SimulationRunResults results) { var command = new OSPSuiteInfoCommand { Description = simulationLabelDescription(results) }; if (results.Warnings.Any()) { command.Comment = AppConstants.Commands.SimulationLabelComment(results.Warnings.Count()); } return(command); }
private IReadOnlyCollection <ScaleDivisor> computerScaleDivisorBasedOn(SimulationRunResults results) { if (!results.Success) { return(new List <ScaleDivisor>()); } var query = from column in results.Results let quantityPath = pathWithoutSimulationName(column.QuantityInfo.PathAsString) let moleculeAmount = _allMoleculeAmounts[quantityPath] where moleculeAmount != null select newScaleDivisor(quantityPath, column); return(query.ToList()); }
private string simulationLabelDescription(SimulationRunResults results) { string terminationString; if (results.Success) { terminationString = "successful"; } else { terminationString = results.Warnings.Any() ? "failed" : "aborted"; } return($"simulation run {terminationString}"); }
protected override void Context() { base.Context(); _simulation = new MoBiSimulation(); _simModelManager = A.Fake <ISimModelManager>(); _outputSelections = new OutputSelections(); _drug = new MoleculeBuilder().WithName("DRUG"); _drug.AddParameter(new Parameter().WithName(AppConstants.Parameters.MOLECULAR_WEIGHT).WithFormula(new ConstantFormula(400))); _outputSelections.AddOutput(new QuantitySelection("A", QuantityType.Drug)); _simulation.BuildConfiguration = new MoBiBuildConfiguration { SimulationSettings = new SimulationSettings { OutputSelections = _outputSelections }, Molecules = new MoleculeBuildingBlock { _drug } }; A.CallTo(() => _simModelManagerFactory.Create()).Returns(_simModelManager); _oldResults = new DataRepository("OLD"); _simulation.Results = _oldResults; _newResults = new DataRepository("NEW"); _simulationResults = new SimulationRunResults(success: true, warnings: Enumerable.Empty <SolverWarning>(), results: _newResults); A.CallTo(() => _simModelManager.RunSimulation(_simulation)).Returns(_simulationResults); var baseGrid = new BaseGrid("Time", DomainHelperForSpecs.TimeDimension); _concentrationColumn = new DataColumn("Drug", DomainHelperForSpecs.ConcentrationDimension, baseGrid); _fractionColumn = new DataColumn("Fraction", DomainHelperForSpecs.FractionDimension, baseGrid); _newResults.Add(_concentrationColumn); _newResults.Add(_fractionColumn); A.CallTo(() => _keyPathMapper.MoleculeNameFrom(_concentrationColumn)).Returns(_drug.Name); }
protected override void Because() { _simulationResult = sut.RunSimulation(); }
protected override void Context() { var entityPathFactory = new EntityPathResolverForSpecs(); _objectPathFactory = new ObjectPathFactory(new AliasCreator()); _simulation = A.Fake <IModelCoreSimulation>().WithName("Sim"); _simModelManager = A.Fake <ISimModelManager>(); _containerTask = A.Fake <IContainerTask>(); _options = new ScaleDivisorOptions(); _moleculeAmountCache = new PathCache <IMoleculeAmount>(entityPathFactory); var rootContainer = new ARootContainer().WithName(_simulation.Name) .WithContainerType(ContainerType.Simulation); _simulation.Model.Root = rootContainer; _moleculeAmount1 = new MoleculeAmount().WithName("M1"); _moleculeAmount2 = new MoleculeAmount().WithName("M2"); rootContainer.Add(_moleculeAmount1); rootContainer.Add(_moleculeAmount2); _moleculeAmountCache.Add(_moleculeAmount1); _moleculeAmountCache.Add(_moleculeAmount2); _molecule1Path = entityPathFactory.PathFor(_moleculeAmount1); _molecule2Path = entityPathFactory.PathFor(_moleculeAmount2); _originalResults = new DataRepository(); _simulation.Results = _originalResults; var baseGrid = new BaseGrid("Time", Constants.Dimension.NO_DIMENSION) { Values = new[] { 0f, 1f, 2f, 3f } }; _originalDataColumn = new DataColumn("M1", Constants.Dimension.NO_DIMENSION, baseGrid) { Values = new[] { 0f, 10f, 20f, 30f } }; _originalDataColumn.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount1); _originalResults.Add(_originalDataColumn); A.CallTo(_containerTask).WithReturnType <PathCache <IMoleculeAmount> >().Returns(_moleculeAmountCache); var simResults = new DataRepository(); var baseGrid2 = new BaseGrid("Time", Constants.Dimension.NO_DIMENSION) { Values = new[] { 0f, 1f, 2f, 3f } }; var res1 = new DataColumn("M1", Constants.Dimension.NO_DIMENSION, baseGrid2) { Values = new[] { 0f, 10f, 20f, 30f } }; res1.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount1); simResults.Add(res1); var res2 = new DataColumn("M2", Constants.Dimension.NO_DIMENSION, baseGrid2) { Values = new[] { 0f, 11f, 12f, 13f } }; res2.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount2); simResults.Add(res2); var simulationRunResults = new SimulationRunResults(true, Enumerable.Empty <ISolverWarning>(), simResults); A.CallTo(() => _simModelManager.RunSimulation(_simulation)).Returns(simulationRunResults); sut = new ScaleDivisorCalculator(_simModelManager, _containerTask, _objectPathFactory); }
protected override void Because() { _res = sut.RunSimulation(_simulation); }