public void test_ListOf_clear() { ListOf lo = new ListOf(); SBase sp = new Species(2,4); lo.append(sp); lo.append(sp); lo.append(sp); lo.append(sp); lo.append(sp); assertTrue( lo.size() == 5 ); lo.clear(true); assertTrue( lo.size() == 0 ); lo.append(sp); lo.append(sp); lo.append(sp); lo.append(sp); lo.appendAndOwn(sp); assertTrue( lo.size() == 5 ); SBase elem; elem = lo.get(0); elem = null; elem = lo.get(1); elem = null; elem = lo.get(2); elem = null; elem = lo.get(3); elem = null; elem = lo.get(4); elem = null; lo.clear(false); assertTrue( lo.size() == 0 ); lo = null; }
static void testListOfRemove(ListOf lof, SBase s) { string ename = s.getElementName(); lof.append(s); SBase c = lof.get(0); if ( c is CompartmentType ) { CompartmentType x = (lof as ListOfCompartmentTypes).remove(0); c = x; } else if ( c is Compartment ) { Compartment x = (lof as ListOfCompartments).remove(0); c = x; } else if ( c is Constraint ) { Constraint x = (lof as ListOfConstraints).remove(0); c = x; } else if ( c is EventAssignment ) { EventAssignment x = (lof as ListOfEventAssignments).remove(0); c = x; } else if ( c is Event ) { Event x = (lof as ListOfEvents).remove(0); c = x; } else if ( c is FunctionDefinition ) { FunctionDefinition x = (lof as ListOfFunctionDefinitions).remove(0); c = x; } else if ( c is InitialAssignment ) { InitialAssignment x = (lof as ListOfInitialAssignments).remove(0); c = x; } else if ( c is Parameter ) { Parameter x = (lof as ListOfParameters).remove(0); c = x; } else if ( c is Reaction ) { Reaction x = (lof as ListOfReactions).remove(0); c = x; } else if ( c is Rule ) { Rule x = (lof as ListOfRules).remove(0); c = x; } else if ( c is Species ) { Species x = (lof as ListOfSpecies).remove(0); c = x; } else if ( c is SpeciesReference ) {SimpleSpeciesReference x = (lof as ListOfSpeciesReferences).remove(0); c = x; } else if ( c is SpeciesType ) { SpeciesType x = (lof as ListOfSpeciesTypes).remove(0); c = x; } else if ( c is UnitDefinition ) { UnitDefinition x = (lof as ListOfUnitDefinitions).remove(0); c = x; } else if ( c is Unit ) { Unit x = (lof as ListOfUnits).remove(0); c = x; } else { ERR("[testListOfRemove] Error: (" + ename + ") : ListOfXXX::remove() failed."); return; } if ( c == null) { ERR("[testListOfRemove] Error: (" + ename + ") : ListOfXXX::remove() failed."); return; } string enameGet = c.getElementName(); if ( ename == enameGet ) { //Console.Out.WriteLine("[testListOfRemove] OK: (" + ename + ") remove(" + enameGet + ") : type match."); OK(); } else { ERR("[testListOfRemove] Error: (" + ename + ") remove(" + enameGet + ") : type mismatch."); } }
public void test_ListOf_copyConstructor() { ListOf o1 = new ListOf(); Species s = new Species(2,1); s.setId("species_1"); o1.append(s); s = null; ListOf o2 = new ListOf(o1); assertTrue( o2.size() == 1 ); assertTrue( ((Species) o2.get(0)).getId() == "species_1" ); assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() ); o2 = null; o1 = null; }
public void test_ListOf_get() { ListOf lo = new ListOf(); assertTrue( lo.size() == 0 ); SBase sp = new Species(2,4); lo.append(sp); assertTrue( lo.size() == 1 ); SBase elem = lo.get(1); assertTrue( sp != elem ); sp = null; lo = null; }