protected override void Context() { base.Context(); var monitor = new ExplicitFormula("TotalDrugMass"); var observer = new ContainerObserverBuilder().WithName("Tralala").WithFormula(monitor); _totalDrugMassReference = new FormulaUsablePath(new[] { "Applications", "TotalDrugMass" }).WithAlias("TotalDrugMass"); monitor.AddObjectPath(_totalDrugMassReference); _observerBuildingBlock = new ObserverBuildingBlock(); _observerBuildingBlock.Add(observer); }
public void TestSerializationObserverBuilderWithoutFormula() { ContainerObserverBuilder x1 = CreateObject <ContainerObserverBuilder>().WithName("Oberon.Builder"); x1.MoleculeList.ForAll = true; x1.AddMoleculeName("H2O"); x1.AddMoleculeName("CO2"); x1.AddMoleculeNameToExclude("NO2"); IObserverBuilder x2 = SerializeAndDeserialize(x1); AssertForSpecs.AreEqualObserverBuilder(x2, x1); }
protected override Task Context() { _descriptorConditionMapper = A.Fake <DescriptorConditionMapper>(); _explicitFormulaMapper = A.Fake <ExplicitFormulaMapper>(); _moleculeListMapper = A.Fake <MoleculeListMapper>(); _objectBaseFactory = A.Fake <IObjectBaseFactory>(); _dimensionRepository = A.Fake <IDimensionRepository>(); _logger = A.Fake <ILogger>(); _dimension = DomainHelperForSpecs.TimeDimensionForSpecs(); _amountObserver = new AmountObserverBuilder { Dimension = _dimension }; _containerObserver = new ContainerObserverBuilder { Dimension = _dimension }; _formula = new OSPSuite.Core.Domain.Formulas.ExplicitFormula("1+2"); _amountObserver.Formula = _formula; _containerObserver.Formula = _formula; _moleculeListSnapshot = new MoleculeList(); _snapshotFormula = new ExplicitFormula(); _newMoleculeList = new OSPSuite.Core.Domain.Builder.MoleculeList(); _newMoleculeList.AddMoleculeNameToExclude("A"); _newMoleculeList.AddMoleculeName("B"); _newMoleculeList.ForAll = false; _newFormula = new OSPSuite.Core.Domain.Formulas.ExplicitFormula("New"); sut = new ObserverMapper( _descriptorConditionMapper, _explicitFormulaMapper, _moleculeListMapper, _objectBaseFactory, _dimensionRepository, _logger); A.CallTo(() => _explicitFormulaMapper.MapToSnapshot(_formula)).Returns(_snapshotFormula); A.CallTo(() => _explicitFormulaMapper.MapToModel(_snapshotFormula)).Returns(_newFormula); A.CallTo(() => _moleculeListMapper.MapToSnapshot(_amountObserver.MoleculeList)).Returns(_moleculeListSnapshot); A.CallTo(() => _moleculeListMapper.MapToSnapshot(_containerObserver.MoleculeList)).Returns(_moleculeListSnapshot); A.CallTo(() => _moleculeListMapper.MapToModel(_moleculeListSnapshot)).Returns(_newMoleculeList); A.CallTo(() => _dimensionRepository.DimensionByName(_dimension.Name)).Returns(_dimension); A.CallTo(() => _objectBaseFactory.Create <AmountObserverBuilder>()).Returns(new AmountObserverBuilder()); A.CallTo(() => _objectBaseFactory.Create <ContainerObserverBuilder>()).Returns(new ContainerObserverBuilder()); return(_completed); }
public void TestSerializationObserverBuilderWithConstantFormula() { ContainerObserverBuilder x1 = CreateObject <ContainerObserverBuilder>() .WithName("Obasi.Builder").WithDimension(DimensionLength); x1.MoleculeList.ForAll = false; x1.AddMoleculeName("H2O"); x1.AddMoleculeName("CO2"); x1.Formula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4); IObserverBuilder x2 = SerializeAndDeserialize(x1); AssertForSpecs.AreEqualObserverBuilder(x2, x1); }
protected override void Context() { base.Context(); var observerBuildingBlock1 = new ObserverBuildingBlock().WithName("Tada"); IObserverBuilder observerBuilderA = new ContainerObserverBuilder().WithName("OBS"); var observerBuilderB = new ContainerObserverBuilder().WithName("ObsB"); observerBuildingBlock1.Add(observerBuilderA); observerBuildingBlock1.Add(observerBuilderB); var observerBuildingBlock2 = new ObserverBuildingBlock().WithName("Tada"); observerBuilderA = new AmountObserverBuilder().WithName("OBS"); observerBuilderB = new ContainerObserverBuilder().WithName("ObsB"); observerBuildingBlock2.Add(observerBuilderA); observerBuildingBlock2.Add(observerBuilderB); _object1 = observerBuildingBlock1; _object2 = observerBuildingBlock2; }
public void TestSerializationObserverBuilderWithExplicitFormula() { ContainerObserverBuilder x1 = CreateObject <ContainerObserverBuilder>().WithName("Oberon.Builder"); x1.ForAll = false; x1.AddMoleculeName("H2O"); x1.AddMoleculeName("CO2"); ExplicitFormula f1 = CreateObject <ExplicitFormula>().WithName("Fortunato").WithDimension(DimensionLength); IFormulaUsablePath fup = new FormulaUsablePath(new string[] { "aa", "bb" }).WithAlias("b").WithDimension(DimensionLength); f1.AddObjectPath(fup); IFormulaCache formulaCache = new FormulaCache(); formulaCache.Add(f1); x1.Formula = formulaCache[f1.Id]; //SerializeAndDeserializeGeneral(formulaCache); IObserverBuilder x2 = SerializeAndDeserialize(x1); AssertForSpecs.AreEqualObserverBuilder(x2, x1); }