Пример #1
0
      public void should_have_set_all_the_container_having_the_name_of_the_compound_to_the_type_molecule()
      {
         var compound = _simulation.BuildingBlock<Compound>().Name;
         var pathResolver = new EntityPathResolverForSpecs();
         var errorList = new List<string>();
         foreach (var container in _simulation.Model.Root.GetAllChildren<IContainer>(x => x.IsNamed(compound)))
         {
            if (container.ContainerType != ContainerType.Molecule)
               errorList.Add(string.Format("{0} {1}", container.ContainerType, pathResolver.PathFor(container)));
         }

         Assert.AreEqual(errorList.Count, 0, errorList.ToString("\n"));
      }
Пример #2
0
        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);
        }