Пример #1
0
        public void TestWriting()
        {
            StringWriter writer   = new StringWriter();
            var          molecule = builder.NewAtomContainer();
            IAtom        atom1    = builder.NewAtom("C");

            atom1.Point3D = new Vector3(1.0, 2.0, 3.0);
            IAtom atom2 = builder.NewAtom("C");

            atom2.Point3D = new Vector3(1.0, 2.0, 3.0);
            molecule.Atoms.Add(atom1);
            molecule.Atoms.Add(atom2);

            XYZWriter xyzWriter = new XYZWriter(writer);

            xyzWriter.Write(molecule);
            xyzWriter.Close();
            writer.Close();

            string output = writer.ToString();
            //        Debug.WriteLine(output);
            // count lines
            int lineCount = 0;
            var reader    = new StringReader(output);

            while (reader.ReadLine() != null)
            {
                lineCount++;
            }
            Assert.AreEqual(4, lineCount);
        }
Пример #2
0
        public void TestSixDecimalOuput()
        {
            StringWriter writer   = new StringWriter();
            var          molecule = builder.NewAtomContainer();
            IAtom        atom1    = builder.NewAtom("C");

            atom1.Point3D = new Vector3(1.0, 2.0, 3.0);
            molecule.Atoms.Add(atom1);
            IAtom atom2 = builder.NewAtom("C");

            atom2.Point3D = new Vector3(-1.5, -2.0, 0.0);
            molecule.Atoms.Add(atom2);

            XYZWriter xyzWriter = new XYZWriter(writer);

            xyzWriter.Write(molecule);
            xyzWriter.Close();
            writer.Close();

            string output = writer.ToString();

            Assert.IsTrue(output.Contains("1.000000"));
            Assert.IsTrue(output.Contains("2.000000"));
            Assert.IsTrue(output.Contains("3.000000"));
        }
Пример #3
0
        public void TestWriting_Point2d()
        {
            StringWriter writer   = new StringWriter();
            var          molecule = builder.NewAtomContainer();
            IAtom        atom1    = builder.NewAtom("C");

            atom1.Point2D = new Vector2(1.0, 2.0);
            molecule.Atoms.Add(atom1);

            XYZWriter xyzWriter = new XYZWriter(writer);

            xyzWriter.Write(molecule);
            xyzWriter.Close();
            writer.Close();

            string output = writer.ToString();

            Assert.IsTrue(output.Contains("0.000000\t 0.000000\t 0.000000"));
        }