Ejemplo n.º 1
0
        public void TestCallingTwice()
        {
            var  molSet = new ChemObjectSet <IAtomContainer>();
            var  mol    = new AtomContainer();
            Atom atom0  = new Atom("C")
            {
                Id = "a1"
            };
            Atom atom2 = new Atom("C");

            mol.Atoms.Add(atom2);
            mol.Atoms.Add(atom0);
            molSet.Add(mol);

            IDCreator.CreateIDs(molSet);
            var ids = MoleculeSetManipulator.GetAllIDs(molSet);

            Assert.AreEqual(4, ids.Count());

            mol = new AtomContainer();
            Atom atom1 = new Atom("C")
            {
                Id = "a2"
            };

            atom2 = new Atom("C");
            mol.Atoms.Add(atom2);
            mol.Atoms.Add(atom1);
            molSet.Add(mol);

            IDCreator.CreateIDs(molSet);
            ids = MoleculeSetManipulator.GetAllIDs(molSet);
            Assert.AreEqual(7, ids.Count());

            mol   = new AtomContainer();
            atom1 = new Atom("C");
            atom2 = new Atom("C");
            mol.Atoms.Add(atom2);
            mol.Atoms.Add(atom1);
            molSet.Add(mol);

            atom0.Id = "atomX";
            ids      = MoleculeSetManipulator.GetAllIDs(molSet);
            Assert.IsFalse(ids.Contains("a1"));

            IDCreator.CreateIDs(molSet);
            var idsAfter = MoleculeSetManipulator.GetAllIDs(molSet);

            Assert.IsTrue(idsAfter.Contains("a1"));
            Assert.AreEqual(10, idsAfter.Count());
        }
Ejemplo n.º 2
0
        public void TestKeepingIDs()
        {
            var  mol  = new AtomContainer();
            Atom atom = new Atom("C")
            {
                Id = "atom1"
            };

            mol.Atoms.Add(atom);

            IDCreator.CreateIDs(mol);

            Assert.AreEqual("atom1", atom.Id);
            Assert.IsNotNull(mol.Id);
            var ids = AtomContainerManipulator.GetAllIDs(mol);

            Assert.AreEqual(2, ids.Count());
        }
Ejemplo n.º 3
0
        public void TestNoDuplicateCreation()
        {
            var  mol   = new AtomContainer();
            Atom atom1 = new Atom("C")
            {
                Id = "a1"
            };
            Atom atom2 = new Atom("C");

            mol.Atoms.Add(atom2);
            mol.Atoms.Add(atom1);

            IDCreator.CreateIDs(mol);
            Assert.AreEqual("a2", atom2.Id);
            var ids = AtomContainerManipulator.GetAllIDs(mol);

            Assert.AreEqual(3, ids.Count());
        }
Ejemplo n.º 4
0
        public void TestCreateIDs_IChemObject()
        {
            var  mol   = new AtomContainer();
            Atom atom1 = new Atom("C");
            Atom atom2 = new Atom("C");

            mol.Atoms.Add(atom1);
            mol.Atoms.Add(atom2);
            Bond bond = new Bond(atom1, atom2);

            mol.Bonds.Add(bond);

            IDCreator.CreateIDs(mol);
            Assert.AreEqual("a1", atom1.Id);
            Assert.AreEqual("b1", bond.Id);
            var ids = AtomContainerManipulator.GetAllIDs(mol);

            Assert.AreEqual(4, ids.Count());
        }