public void TestReadIsotopes2() { var isotopeData = "<?xml version=\"1.0\"?>" + "<list xmlns=\"http://www.xml-cml.org/schema/cml2/core\"" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xsi:schemaLocation=\"http://www.xml-cml.org/schema/cml2/core ../../io/cml/data/cmlCore.xsd\">" + "" + " <isotopeList id=\"H\">" + " <isotope id=\"H1\" isotopeNumber=\"1\" elementType=\"H\">" + " <abundance dictRef=\"cdk:relativeAbundance\">100.0</abundance>" + " <scalar dictRef=\"cdk:exactMass\">1.00782504</scalar>" + " <scalar dictRef=\"cdk:atomicNumber\">1</scalar>" + " </isotope>" + " <isotope id=\"H2\" isotopeNumber=\"2\" elementType=\"H\">" + " <abundance dictRef=\"cdk:relativeAbundance\">0.015</abundance>" + " <scalar dictRef=\"cdk:exactMass\">2.01410179</scalar>" + " <scalar dictRef=\"cdk:atomicNumber\">1</scalar>" + " </isotope>" + " <isotope id=\"D2\" isotopeNumber=\"2\" elementType=\"D\">" + " <abundance dictRef=\"cdk:relativeAbundance\">0.015</abundance>" + " <scalar dictRef=\"cdk:exactMass\">2.01410179</scalar>" + " <scalar dictRef=\"cdk:atomicNumber\">1</scalar>" + " </isotope>" + " </isotopeList>" + "</list>"; IsotopeReader reader = new IsotopeReader(new MemoryStream(Encoding.UTF8.GetBytes(isotopeData))); Assert.IsNotNull(reader); var isotopes = reader.ReadIsotopes(); Assert.IsNotNull(isotopes); Assert.AreEqual(3, isotopes.Count); }
public void TestReadIsotopes() { IsotopeReader reader = new IsotopeReader(new MemoryStream(Encoding.UTF8.GetBytes("<?xml version=\"1.0\"?><list></list>"))); Assert.IsNotNull(reader); var isotopes = reader.ReadIsotopes(); Assert.IsNotNull(isotopes); Assert.AreEqual(0, isotopes.Count); }
/// <summary> /// Private constructor for the IsotopeFactory object. /// </summary> /// <exception cref="IOException">A problem with reading the isotopes.xml file</exception> private XMLIsotopeFactory() { Trace.TraceInformation("Creating new IsotopeFactory"); // ObjIn in = null; var errorMessage = $"There was a problem getting NCDK.Config.Data.isotopes.xml as a stream"; var configFile = "NCDK.Config.Data.isotopes.xml"; Debug.WriteLine($"Getting stream for {configFile}"); using (var reader = new IsotopeReader(ResourceLoader.GetAsStream(configFile))) { var isotopes = reader.ReadIsotopes(); foreach (var isotope in isotopes) { Add(isotope); } Debug.WriteLine($"Found #isotopes in file: {isotopes.Count}"); } }