Esempio n. 1
0
        public void TestNewLonePair_IAtom()
        {
            IChemObjectBuilder builder  = RootObject.Builder;
            ILonePair          lonePair = builder.NewLonePair(builder.NewAtom());

            Assert.IsNotNull(lonePair);
        }
Esempio n. 2
0
        public void TestDontDeleteSingleElectrons()
        {
            var atomCon = builder.NewAtomContainer();
            // make two molecules; one with an LonePair, the other with a SingleElectron
            var mol1  = builder.NewAtomContainer();
            var atom1 = builder.NewAtom("C");

            mol1.Atoms.Add(atom1);
            var lp1 = builder.NewLonePair(atom1);

            mol1.LonePairs.Add(lp1);
            // mol2
            var mol2  = builder.NewAtomContainer();
            var atom2 = builder.NewAtom("C");

            mol2.Atoms.Add(atom2);
            var se2 = builder.NewSingleElectron(atom2);

            mol2.SingleElectrons.Add(se2);

            atomCon.Add(mol1);
            atomCon.Add(mol2);

            // now partition
            var moleculeSet = ConnectivityChecker.PartitionIntoMolecules(atomCon).ToReadOnlyList();

            Assert.IsNotNull(moleculeSet);
            Assert.AreEqual(2, moleculeSet.Count);

            Assert.IsTrue(ConnectivityChecker.IsConnected(moleculeSet[0]));
            Assert.IsTrue(ConnectivityChecker.IsConnected(moleculeSet[1]));

            // make sure
            Assert.AreEqual(1, moleculeSet[0].Atoms.Count);
            Assert.AreEqual(1, moleculeSet[0].GetElectronContainers().Count());
            Assert.AreEqual(1, moleculeSet[1].Atoms.Count);
            Assert.AreEqual(1, moleculeSet[1].GetElectronContainers().Count());
            // we don't know which partition contains the LP and which the electron
            Assert.IsTrue(moleculeSet[0].GetConnectedSingleElectrons(
                              moleculeSet[0].Atoms[0]).Count() == 0 ||
                          moleculeSet[1].GetConnectedSingleElectrons(
                              moleculeSet[1].Atoms[0]).Count() == 0);
            Assert.IsTrue(moleculeSet[0].GetConnectedLonePairs(
                              moleculeSet[0].Atoms[0]).Count() == 0 ||
                          moleculeSet[1].GetConnectedLonePairs(
                              moleculeSet[1].Atoms[0]).Count() == 0);
        }