public void TestTaxols() { var filename = "NCDK.Data.ASN.PubChem.taxols.xml"; Trace.TraceInformation("Testing: " + filename); int modelCount = 0; IChemSequence set; using (var ins = ResourceLoader.GetAsStream(filename)) using (var sr = new StreamReader(ins)) using (var reader = new EnumerablePCSubstancesXMLReader(sr, ChemObjectBuilder.Instance)) { set = ChemObjectBuilder.Instance.NewChemSequence(); foreach (var obj in reader) { Assert.IsNotNull(obj); Assert.IsTrue(obj is IChemModel); set.Add((IChemModel)obj); modelCount++; } } Assert.AreEqual(77, modelCount); IChemModel first = set[0]; Assert.AreEqual(63, ChemModelManipulator.GetAtomCount(first)); Assert.AreEqual(69, ChemModelManipulator.GetBondCount(first)); }
void AssertAtomCount(int expectedAtomCount, IChemObject chemObject) { if (expectedAtomCount != -1) { if (chemObject is IChemFile) { Assert.AreEqual(expectedAtomCount, ChemFileManipulator.GetAtomCount((IChemFile)chemObject)); } else if (chemObject is IChemModel) { Assert.AreEqual(expectedAtomCount, ChemModelManipulator.GetAtomCount((IChemModel)chemObject)); } else if (chemObject is IAtomContainer) { Assert.AreEqual(expectedAtomCount, ((IAtomContainer)chemObject).Atoms.Count); } else if (chemObject is IReaction) { Assert.AreEqual(expectedAtomCount, ReactionManipulator.GetAtomCount((IReaction)chemObject)); } } }