Exemplo n.º 1
0
        static SBMLDocument testReadSBMLFromString(string file)
        {
            if (!File.Exists(file))
            {
                ERR("[ReadSBMLFromString] Error: (" + file + ") : No such file or directory.");
                return(null);
            }

            StreamReader oReader = new StreamReader(file);
            string       sSBML   = oReader.ReadToEnd();

            SBMLDocument d = libsbml.readSBMLFromString(sSBML);

            if (d == null)
            {
                ERR("[ReadSBMLFromString] Error: (" + file + ") SBMLDocument is null.");
                return(null);
            }

            if (d.getModel() == null)
            {
                for (int i = 0; i < d.getNumErrors(); i++)
                {
                    ERR("[ReadSBMLFromString] Error: (" + file + ") : " + d.getError(i).getMessage());
                }
                return(null);
            }
            else if (d.getNumErrors() > 0)
            {
                bool iserror = false;
                for (int i = 0; i < d.getNumErrors(); i++)
                {
                    long severity = d.getError(i).getSeverity();
                    if ((severity == libsbml.LIBSBML_SEV_ERROR) ||
                        (severity == libsbml.LIBSBML_SEV_FATAL)
                        )
                    {
                        iserror = true;
                        ERR("[ReadSBMLFromString] Error: (" + file + ") : " + d.getError(i).getMessage());
                    }
                }
                if (iserror)
                {
                    return(null);
                }
            }

            OK();

            return(d);
        }
Exemplo n.º 2
0
        public void test_WriteL3SBML_error()
        {
            SBMLDocument d = new SBMLDocument();
            SBMLWriter   w = new SBMLWriter();

            assertEquals(false, w.writeSBML(d, "/tmp/impossible/path/should/fail"));
            assertTrue(d.getNumErrors() == 1);
            assertTrue(d.getError(0).getErrorId() == libsbml.XMLFileUnwritable);
            d = null;
            w = null;
        }