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; }
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_isVariantOfSubstancePerTime_4() { UnitDefinition ud = new UnitDefinition(2, 2); Unit dim = ud.createUnit(); 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_KILOGRAM); 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; }
public void test_UnitDefinition_addUnit4() { UnitDefinition m = new UnitDefinition(2, 2); Unit p = null; int i = m.addUnit(p); assertTrue(i == libsbml.LIBSBML_OPERATION_FAILED); assertTrue(m.getNumUnits() == 0); m = null; }
public void test_UnitDefinition_addUnit3() { UnitDefinition m = new UnitDefinition(2, 2); Unit p = new Unit(1, 2); p.setKind(libsbml.UNIT_KIND_MOLE); int i = m.addUnit(p); assertTrue(i == libsbml.LIBSBML_LEVEL_MISMATCH); assertTrue(m.getNumUnits() == 0); p = null; m = null; }
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; }
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; }
protected override void Because() { sut = IoC.Resolve <IUnitDefinitionImporter>(); //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); _unit3 = _sbmlModel.createUnit(); _unit3.setExponent(-1); _unit3.setMultiplier(1 / 86400.0); //86400 seconds in one day _unit3.setScale(0); _unit3.setKind(libsbml.UnitKind_forName("second")); _unitDef3 = _sbmlModel.createUnitDefinition(); _unitDef3.setId("inverse_day"); _unitDef3.setName("1/d"); _unitDef3.addUnit(_unit3); _sbmlModel.addUnitDefinition(_unitDef); sut.DoImport(_sbmlModel, new MoBiProject(), A.Fake <SBMLInformation>(), new MoBiMacroCommand()); }
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_UnitDefinition_addUnit() { Unit u = new Unit(2, 4); u.setKind(libsbml.UNIT_KIND_MOLE); UD.addUnit(u); assertTrue(UD.getNumUnits() == 1); u = null; }