コード例 #1
0
  /** This tests the getMagnitudeValueAsNumber method. */
  public void testGetMagnitudeValueAsNumber() {
    MutableQuantityValue mutableQuantityValue = new MutableQuantityValueImpl();

    NumberValueImpl numberValue = new MutableNumberValueImpl();
    numberValue.setValue(new Double(10));
    mutableQuantityValue.setMagnitudeValue(numberValue);

    UnitValue unitValue = QuantityUnits.CENTIMETERS;
    mutableQuantityValue.setUnitValue(unitValue);

    Number expectedResultInMillimeters = new Double(100);
    Number result = mutableQuantityValue.getMagnitudeAsNumber(QuantityUnits.MILLIMETERS);

    assertEquals("CM to MM Conversion failure", expectedResultInMillimeters, result);

    // todo add tests for other conversions
  }