/// /// @file TestAssignmentRule.cs /// @brief AssignmentRule unit tests /// @author Frank Bergmann (Csharp conversion) /// @author Akiya Jouraku (Csharp conversion) /// @author Ben Bornstein /// /// $Id: TestAssignmentRule.cs 8704 2009-01-04 02:26:05Z mhucka $ /// $HeadURL: https://sbml.svn.sourceforge.net/svnroot/sbml/trunk/libsbml/src/bindings/csharp/test/sbml/TestAssignmentRule.cs $ /// /// This test file was converted from src/sbml/test/TestAssignmentRule.c /// with the help of conversion sciprt (ctest_converter.pl). /// /// */ namespace LibSBMLCSTest { using libsbml; using System.IO; public class TestAssignmentRule { 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 AR; public void setUp() { AR = new AssignmentRule(); if (AR == null); { } } public void tearDown() { AR = null; } public void test_AssignmentRule_L2_create() { assertTrue( AR.getTypeCode() == libsbml.SBML_ASSIGNMENT_RULE ); assertTrue( AR.getMetaId() == "" ); assertTrue( AR.getNotes() == null ); assertTrue( AR.getAnnotation() == null ); assertTrue( AR.getFormula() == "" ); assertTrue( AR.getMath() == null ); assertTrue( AR.getVariable() == "" ); assertTrue( AR.getType() == libsbml.RULE_TYPE_SCALAR ); } public void test_AssignmentRule_createWithFormula() { ASTNode math; string formula; Rule ar = new AssignmentRule("s", "1 + 1"); assertTrue( ar.getTypeCode() == libsbml.SBML_ASSIGNMENT_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_AssignmentRule_createWithLevelVersionAndNamespace() { XMLNamespaces xmlns = new XMLNamespaces(); xmlns.add( "http://www.sbml.org", "sbml"); Rule object1 = new AssignmentRule(2,1,xmlns); assertTrue( object1.getTypeCode() == libsbml.SBML_ASSIGNMENT_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_AssignmentRule_createWithMath() { ASTNode math = libsbml.parseFormula("1 + 1"); Rule ar = new AssignmentRule("s",math); assertTrue( ar.getTypeCode() == libsbml.SBML_ASSIGNMENT_RULE ); assertTrue( ar.getMetaId() == "" ); assertTrue(( "s" == ar.getVariable() )); assertTrue(( "1 + 1" == ar.getFormula() )); assertTrue( ar.getMath() != math ); ar = null; } public void test_AssignmentRule_free_NULL() { } public void test_AssignmentRule_setVariable() { string variable = "x";; AR.setVariable(variable); assertTrue(( variable == AR.getVariable() )); assertEquals( true, AR.isSetVariable() ); if (AR.getVariable() == variable); { } AR.setVariable(AR.getVariable()); assertTrue(( variable == AR.getVariable() )); AR.setVariable(""); assertEquals( false, AR.isSetVariable() ); if (AR.getVariable() != null); { } } } }