setKind() public method

public setKind ( int kind ) : int
kind int
return int
Example #1
0
            protected override void Because()
            {
                _dimensionFactoy = IoC.Resolve <IMoBiDimensionFactory>();
                sut = new UnitDefinitionImporter(IoC.Resolve <IObjectPathFactory>(), IoC.Resolve <IObjectBaseFactory>(), _dimensionFactoy, IoC.Resolve <ASTHandler>(), A.Fake <IMoBiContext>());
                //create unit "substance"
                _unit = new Unit(3, 1);
                _unit.setExponent(1);
                _unit.setMultiplier(1.0);
                _unit.setScale(0);
                _unit.setKind(libsbml.UNIT_KIND_MOLE);

                //create unitdef "substance"
                _unitDef = _sbmlModel.createUnitDefinition();
                _unitDef.setId("substance");
                _unitDef.setName("substance");
                _unitDef.addUnit(_unit);

                //create unit "volume"
                _unit2 = _sbmlModel.createUnit();
                _unit2.setExponent(1);
                _unit2.setMultiplier(1.0);
                _unit2.setScale(0);
                _unit2.setKind(libsbml.UnitKind_forName("volume"));

                //create unitdef "volume"
                _unitDef2 = _sbmlModel.createUnitDefinition();
                _unitDef2.setId("volume");
                _unitDef2.setName("volume");
                _unitDef2.addUnit(_unit2);

                _sbmlModel.addUnitDefinition(_unitDef);
                sut.DoImport(_sbmlModel, new MoBiProject(), A.Fake <SBMLInformation>(), new MoBiMacroCommand());
                _substanceDimension = _dimensionFactoy.Dimension("SBML_substance");
                _volumeDimension    = _dimensionFactoy.Dimension("Volume");
            }
 public void test_UnitDefinition_addUnit()
 {
     Unit u = new  Unit(2,4);
       u.setKind(libsbml.UNIT_KIND_MOLE);
       UD.addUnit(u);
       assertTrue( UD.getNumUnits() == 1 );
       u = null;
 }
 public void test_UnitDefinition_addUnit2()
 {
     UnitDefinition m = new  UnitDefinition(2,2);
       Unit p = new  Unit(2,1);
       p.setKind(libsbml.UNIT_KIND_MOLE);
       int i = m.addUnit(p);
       assertTrue( i == libsbml.LIBSBML_VERSION_MISMATCH );
       assertTrue( m.getNumUnits() == 0 );
       p = null;
       m = null;
 }
 public void test_UnitDefinition_addUnit1()
 {
     UnitDefinition m = new  UnitDefinition(2,2);
       Unit p = new  Unit(2,2);
       int i = m.addUnit(p);
       assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT );
       p.setKind(libsbml.UNIT_KIND_MOLE);
       i = m.addUnit(p);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumUnits() == 1 );
       p = null;
       m = null;
 }
 public void test_UnitDefinition_isVariantOfVolume_2()
 {
     Unit dim = new  Unit(2,4);
       dim.setKind(libsbml.UnitKind_forName("dimensionless"));
       Unit u = UD.createUnit();
       assertEquals( false, UD.isVariantOfVolume() );
       u.setKind(libsbml.UNIT_KIND_METRE);
       u.setExponent(3);
       assertEquals( true, UD.isVariantOfVolume() );
       u.setScale(100);
       assertEquals( true, UD.isVariantOfVolume() );
       u.setMultiplier(5);
       assertEquals( true, UD.isVariantOfVolume() );
       u.setOffset(-5);
       assertEquals( true, UD.isVariantOfVolume() );
       u.setExponent(2);
       assertEquals( false, UD.isVariantOfVolume() );
       u.setExponent(3);
       UD.addUnit(dim);
       assertEquals( true, UD.isVariantOfVolume() );
 }
 public void test_UnitDefinition_isVariantOfSubstancePerTime_3()
 {
     UnitDefinition ud = new  UnitDefinition(2,2);
       Unit dim = new  Unit(2,2);
       dim.setKind(libsbml.UnitKind_forName("dimensionless"));
       Unit perTime = ud.createUnit();
       perTime.setKind(libsbml.UnitKind_forName("second"));
       perTime.setExponent(-1);
       Unit u = ud.createUnit();
       assertEquals( false, ud.isVariantOfSubstancePerTime() );
       u.setKind(libsbml.UNIT_KIND_GRAM);
       u.setExponent(1);
       assertEquals( true, ud.isVariantOfSubstancePerTime() );
       u.setScale(-1);
       perTime.setScale(-1);
       assertEquals( true, ud.isVariantOfSubstancePerTime() );
       u.setMultiplier(2);
       assertEquals( true, ud.isVariantOfSubstancePerTime() );
       u.setOffset(3);
       assertEquals( true, ud.isVariantOfSubstancePerTime() );
       u.setExponent(-3);
       assertEquals( false, ud.isVariantOfSubstancePerTime() );
       u.setExponent(1);
       perTime.setExponent(-3);
       assertEquals( false, ud.isVariantOfSubstancePerTime() );
       perTime.setExponent(-1);
       ud.addUnit(dim);
       assertEquals( true, ud.isVariantOfSubstancePerTime() );
       ud = null;
       dim = null;
 }
 public void test_UnitDefinition_getUnit()
 {
     Unit mole = new  Unit(2,4);
       Unit litre = new  Unit(2,4);
       Unit second = new  Unit(2,4);
       mole.setKind(libsbml.UnitKind_forName("mole"));
       litre.setKind(libsbml.UnitKind_forName("litre"));
       second.setKind(libsbml.UnitKind_forName("second"));
       mole.setScale(-3);
       litre.setExponent(-1);
       second.setExponent(-1);
       UD.addUnit(mole);
       UD.addUnit(litre);
       UD.addUnit(second);
       mole = null;
       litre = null;
       second = null;
       assertTrue( UD.getNumUnits() == 3 );
       mole = UD.getUnit(0);
       litre = UD.getUnit(1);
       second = UD.getUnit(2);
       assertTrue( mole.getKind() == libsbml.UNIT_KIND_MOLE );
       assertTrue( litre.getKind() == libsbml.UNIT_KIND_LITRE );
       assertTrue( second.getKind() == libsbml.UNIT_KIND_SECOND );
       assertTrue( mole.getScale() == -3 );
       assertTrue( litre.getExponent() == -1 );
       assertTrue( second.getExponent() == -1 );
 }
 public void test_Unit_parent_add()
 {
     UnitDefinition ud = new UnitDefinition(2,4);
       Unit u = new Unit(2,4);
       u.setKind(libsbml.UNIT_KIND_MOLE);
       ud.addUnit(u);
       u = null;
       assertTrue( ud.getNumUnits() == 1 );
       ListOf lo = ud.getListOfUnits();
       assertTrue( lo == ud.getUnit(0).getParentSBMLObject() );
       assertTrue( ud == lo.getParentSBMLObject() );
       ud = null;
 }
Example #9
0
 public void test_Unit_set_get()
 {
     Unit u = new  Unit(2,4);
       assertTrue( u.getKind() == libsbml.UNIT_KIND_INVALID );
       assertTrue( u.getExponent() == 1 );
       assertTrue( u.getScale() == 0 );
       assertTrue( u.getMultiplier() == 1.0 );
       assertEquals( false, u.isSetKind() );
       u.setKind(libsbml.UNIT_KIND_WATT);
       assertTrue( u.getKind() == libsbml.UNIT_KIND_WATT );
       u.setExponent(3);
       assertTrue( u.getExponent() == 3 );
       u.setScale(4);
       assertTrue( u.getScale() == 4 );
       u.setMultiplier(3.2);
       assertTrue( u.getMultiplier() == 3.2 );
       u = null;
 }
 public void test_Unit_ancestor_add()
 {
     UnitDefinition ud = new UnitDefinition(2,4);
       Unit u = new Unit(2,4);
       u.setKind(libsbml.UNIT_KIND_MOLE);
       ud.addUnit(u);
       u = null;
       assertTrue( ud.getNumUnits() == 1 );
       ListOf lo = ud.getListOfUnits();
       Unit obj = ud.getUnit(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_UNIT_DEFINITION) == ud );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null );
       ud = null;
 }
Example #11
0
 public void test_L3_Unit_hasRequiredAttributes()
 {
     Unit u = new  Unit(3,1);
       assertEquals( false, u.hasRequiredAttributes() );
       u.setKind(libsbml.UNIT_KIND_MOLE);
       assertEquals( false, u.hasRequiredAttributes() );
       u.setExponent(0);
       assertEquals( false, u.hasRequiredAttributes() );
       u.setMultiplier(0.45);
       assertEquals( false, u.hasRequiredAttributes() );
       u.setScale(2);
       assertEquals( true, u.hasRequiredAttributes() );
       u = null;
 }
 public void test_internal_consistency_check_99925()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       Unit u = new Unit(2,4);
       d.setLevelAndVersion(1,2,false);
       Model m = d.createModel();
       Compartment c = m.createCompartment();
       c.setId("cc");
       UnitDefinition ud = m.createUnitDefinition();
       ud.setId("ud");
       u.setKind(libsbml.UNIT_KIND_MOLE);
       u.setOffset(9);
       ud.addUnit(u);
       errors = d.checkInternalConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
 public void test_Unit()
 {
     Unit u = new Unit(2,4);
       assertEquals( false, (u.hasRequiredAttributes()) );
       u.setKind(libsbml.UNIT_KIND_MOLE);
       assertEquals( true, u.hasRequiredAttributes() );
       u = null;
 }
 public void test_SBMLDocument_setLevelAndVersion_Error()
 {
     SBMLDocument d = new  SBMLDocument();
       d.setLevelAndVersion(2,1,true);
       Model m1 = new  Model(2,1);
       Unit u = new  Unit(2,1);
       u.setKind(libsbml.UnitKind_forName("mole"));
       u.setOffset(3.2);
       UnitDefinition ud = new  UnitDefinition(2,1);
       ud.setId( "ud");
       ud.addUnit(u);
       m1.addUnitDefinition(ud);
       d.setModel(m1);
       assertTrue( d.setLevelAndVersion(2,2,true) == false );
       assertTrue( d.setLevelAndVersion(2,3,true) == false );
       assertTrue( d.setLevelAndVersion(1,2,true) == false );
       assertTrue( d.setLevelAndVersion(1,1,true) == false );
       d = null;
 }
 public void test_Unit_copyConstructor()
 {
     Unit o1 = new Unit(2,4);
       o1.setKind(libsbml.UNIT_KIND_MOLE);
       assertTrue( o1.getKind() == libsbml.UNIT_KIND_MOLE );
       Unit o2 = new Unit(o1);
       assertTrue( o2.getKind() == libsbml.UNIT_KIND_MOLE );
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }
 public void test_Unit_assignmentOperator()
 {
     Unit o1 = new Unit(2,4);
       o1.setKind(libsbml.UNIT_KIND_MOLE);
       assertTrue( o1.getKind() == libsbml.UNIT_KIND_MOLE );
       Unit o2 = new Unit(2,4);
       o2 = o1;
       assertTrue( o2.getKind() == libsbml.UNIT_KIND_MOLE );
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }