/// /// @file TestRateRule.cs /// @brief RateRule unit tests /// @author Frank Bergmann (Csharp conversion) /// @author Akiya Jouraku (Csharp conversion) /// @author Ben Bornstein /// /// $Id: TestRateRule.cs 8704 2009-01-04 02:26:05Z mhucka $ /// $HeadURL: https://sbml.svn.sourceforge.net/svnroot/sbml/trunk/libsbml/src/bindings/csharp/test/sbml/TestRateRule.cs $ /// /// This test file was converted from src/sbml/test/TestRateRule.c /// with the help of conversion sciprt (ctest_converter.pl). /// /// */ namespace LibSBMLCSTest { using libsbml; using System.IO; public class TestRateRule { public class AssertionError : System.Exception { public AssertionError() : base() { } } static void assertTrue(bool condition) { if (condition == true) { return; } throw new AssertionError(); } static void assertEquals(object a, object b) { if ( (a == null) && (b == null) ) { return; } else if (a.Equals(b)) { return; } throw new AssertionError(); } static void assertNotEquals(object a, object b) { if ( (a == null) && (b == null) ) { throw new AssertionError(); } else if (a.Equals(b)) { throw new AssertionError(); } } static void assertEquals(bool a, bool b) { if ( a == b ) { return; } throw new AssertionError(); } static void assertNotEquals(bool a, bool b) { if ( a != b ) { return; } throw new AssertionError(); } static void assertEquals(int a, int b) { if ( a == b ) { return; } throw new AssertionError(); } static void assertNotEquals(int a, int b) { if ( a != b ) { return; } throw new AssertionError(); } private Rule RR; public void setUp() { RR = new RateRule(); if (RR == null); { } } public void tearDown() { RR = null; } public void test_RateRule_create() { assertTrue( RR.getTypeCode() == libsbml.SBML_RATE_RULE ); assertTrue( RR.getMetaId() == "" ); assertTrue( RR.getNotes() == null ); assertTrue( RR.getAnnotation() == null ); assertTrue( RR.getFormula() == "" ); assertTrue( RR.getMath() == null ); assertTrue( RR.getVariable() == "" ); assertTrue( RR.getType() == libsbml.RULE_TYPE_RATE ); } public void test_RateRule_createWithFormula() { ASTNode math; string formula; Rule ar = new RateRule("s", "1 + 1"); assertTrue( ar.getTypeCode() == libsbml.SBML_RATE_RULE ); assertTrue( ar.getMetaId() == "" ); assertTrue(( "s" == ar.getVariable() )); math = ar.getMath(); assertTrue( math != null ); formula = libsbml.formulaToString(math); assertTrue( formula != null ); assertTrue(( "1 + 1" == formula )); assertTrue(( formula == ar.getFormula() )); ar = null; } public void test_RateRule_createWithLevelVersionAndNamespace() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "sbml"); Rule object1 = new RateRule(2,1,xmlns); assertTrue( object1.getTypeCode() == libsbml.SBML_RATE_RULE ); assertTrue( object1.getMetaId() == "" ); assertTrue( object1.getNotes() == null ); assertTrue( object1.getAnnotation() == null ); assertTrue( object1.getLevel() == 2 ); assertTrue( object1.getVersion() == 1 ); assertTrue( object1.getNamespaces() != null ); assertTrue( object1.getNamespaces().getLength() == 1 ); object1 = null; } public void test_RateRule_createWithMath() { ASTNode math = libsbml.parseFormula("1 + 1"); Rule ar = new RateRule("s",math); assertTrue( ar.getTypeCode() == libsbml.SBML_RATE_RULE ); assertTrue( ar.getMetaId() == "" ); assertTrue(( "s" == ar.getVariable() )); assertTrue(( "1 + 1" == ar.getFormula() )); assertTrue( ar.getMath() != math ); ar = null; } public void test_RateRule_free_NULL() { } public void test_RateRule_setVariable() { string variable = "x";; RR.setVariable(variable); assertTrue(( variable == RR.getVariable() )); assertEquals( true, RR.isSetVariable() ); if (RR.getVariable() == variable); { } RR.setVariable(RR.getVariable()); assertTrue(( variable == RR.getVariable() )); RR.setVariable(""); assertEquals( false, RR.isSetVariable() ); if (RR.getVariable() != null); { } } } }