コード例 #1
0
        private void convert(IMoleculeBuilder moleculeBuilder, IMoleculeBuildingBlock moleculeBuildingBlock, IReadOnlyList <IPassiveTransportBuildingBlock> passiveTransportBuildingBlocks)
        {
            var allPassiveTransports = moleculeBuilder.GetChildren <ITransportBuilder>().ToList();

            if (!allPassiveTransports.Any())
            {
                return;
            }

            foreach (var passiveTransport in allPassiveTransports)
            {
                moleculeBuilder.RemoveChild(passiveTransport);
                var defaultName = AppConstants.CompositeNameFor(passiveTransport.Name, moleculeBuilder.Name);

                foreach (var passiveTransportBuildingBlock in passiveTransportBuildingBlocks)
                {
                    if (similarPassiveTransportAlreadyExists(passiveTransportBuildingBlock, passiveTransport, defaultName))
                    {
                        var existingPassiveTransport = passiveTransportBuildingBlock.FindByName(defaultName);
                        existingPassiveTransport.AddMoleculeName(moleculeBuilder.Name);
                        continue;
                    }

                    var passiveTransportClone = _cloneManager.Clone(passiveTransport);
                    passiveTransportClone.Name   = _containerTask.CreateUniqueName(passiveTransportBuildingBlock, defaultName, canUseBaseName: true);
                    passiveTransportClone.ForAll = false;
                    passiveTransportClone.AddMoleculeName(moleculeBuilder.Name);
                    passiveTransportClone.Parameters.Each(x => x.BuildMode = ParameterBuildMode.Local);
                    passiveTransportBuildingBlock.Add(passiveTransportClone);
                    passiveTransportBuildingBlock.AddFormula(passiveTransportClone.Formula);
                }

                if (moleculeBuildingBlock != null)
                {
                    moleculeBuildingBlock.FormulaCache.Remove(passiveTransport.Formula);
                }
            }
        }
コード例 #2
0
 public void should_have_renamed_the_passive_transport_to_contain_the_name_of_the_molecule()
 {
     _clonedPassiveTransport.Name.ShouldBeEqualTo(AppConstants.CompositeNameFor(_passiveTransport.Name, _moleculeWithPassiveTransport.Name));
 }