public void GivenBaseNumberWhenSubtractDoubleShouldReturnNewBaseNumberWithDoubleSubtractedFromSource() { var uom = _mileUnitOfMeasure; var number = new NumericValue(uom.ToModelUom(), 3.62); var result = number.Subtract(1.23); Assert.AreEqual(2.39, result.Value, Epsilon); }
public void GivenBaseNumbersWithIncompatibleUnitsWhenSubtractThenException() { var originalUom = InternalUnitSystemManager.Instance.UnitOfMeasures["m"]; var originalNumber = new NumericValue(originalUom.ToModelUom(), 1.75); var secondUom = InternalUnitSystemManager.Instance.UnitOfMeasures["C"]; var secondNumber = new NumericValue(secondUom.ToModelUom(), 3.5); Assert.Throws <InvalidOperationException>(() => originalNumber.Subtract(secondNumber)); }
public void GivenTwoBaseNumbersWithSameUomWhenSubtractedReturnNewBaseNumberWithDifferenceAsSourceValue() { var uom = InternalUnitSystemManager.Instance.UnitOfMeasures["C"]; var originalNumber = new NumericValue(uom.ToModelUom(), 22); var secondNumber = new NumericValue(uom.ToModelUom(), 13); var result = originalNumber.Subtract(secondNumber); Assert.AreEqual(9, result.Value); }
public void GivenBaseNumberWhenSubtractBaseNumberThenResultIsInOriginalUom() { var originalUom = InternalUnitSystemManager.Instance.UnitOfMeasures["m"]; var originalNumber = new NumericValue(originalUom.ToModelUom(), 1.75); var secondUom = InternalUnitSystemManager.Instance.UnitOfMeasures["ft"]; var secondNumber = new NumericValue(secondUom.ToModelUom(), 3.5); var expected = 0.6832; //1.75m - (3.5ft -> m) var actual = originalNumber.Subtract(secondNumber); Assert.AreEqual(expected, actual.Value, Epsilon); }