public void GivenVariableNumberWhenSubtractDoubleShouldReturnNewVariableNumberWithDoubleSubtractedFromSource() { var uom = InternalUnitSystemManager.Instance.UnitOfMeasures["mi"].ToModelUom(); var value = new NumericValue(uom, 3.62); var number = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), value); var result = number.Subtract(1.23); Assert.IsInstanceOf <NumericRepresentationValue>(result); Assert.AreEqual(2.39, result.Value.Value, Epsilon); }
public void GivenVariableNumbersWithIncompatibleUnitsWhenSubtractThenException() { var originalUom = InternalUnitSystemManager.Instance.UnitOfMeasures["m"].ToModelUom(); var originalValue = new NumericValue(originalUom, 1.75); var originalNumber = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), originalValue); var secondUom = InternalUnitSystemManager.Instance.UnitOfMeasures["C"].ToModelUom(); var secondValue = new NumericValue(secondUom, 3.5); var secondNumber = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), secondValue); Assert.Throws <InvalidOperationException>(() => originalNumber.Subtract(secondNumber)); }
public void GivenTwoVariableNumbersWithSameUomWhenSubtractedThenSourceValueIsDifference() { var uom = InternalUnitSystemManager.Instance.UnitOfMeasures["C"].ToModelUom(); var originalValue = new NumericValue(uom, 22); var originalNumber = new NumericRepresentationValue(RepresentationInstanceList.vrAirTemperature.ToModelRepresentation(), originalValue); var secondNumber = new NumericValue(uom, 13); var result = originalNumber.Subtract(secondNumber); Assert.IsInstanceOf <NumericRepresentationValue>(result); Assert.AreEqual(9, result.Value.Value); }
public void GivenTwoVariableNubmersWhenSubtractedThenRepresentationIsOriginal() { var originalUom = _ftUnitOfMeasure.ToModelUom(); var originalValue = new NumericValue(originalUom, 22); var originalNumber = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), originalValue); var secondUom = InternalUnitSystemManager.Instance.UnitOfMeasures["m"].ToModelUom(); var secondValue = new NumericValue(secondUom, 11); var secondNumber = new NumericRepresentationValue(RepresentationInstanceList.vrElevation.ToModelRepresentation(), secondValue); var result = originalNumber.Subtract(secondNumber); Assert.AreSame(RepresentationInstanceList.vrDistanceTraveled.DomainId, result.Representation.Code); }
public void GivenVariableNumberWhenSubtractVariableNumberThenResultIsInOriginalUom() { var originalUom = InternalUnitSystemManager.Instance.UnitOfMeasures["m"].ToModelUom(); var originalValue = new NumericValue(originalUom, 1.75); var originalNumber = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), originalValue); var secondUom = _ftUnitOfMeasure.ToModelUom(); var secondNumber = new NumericValue(secondUom, 3.5); var expected = 0.6832; //1.75m + (3.5ft -> m) var actual = originalNumber.Subtract(secondNumber); Assert.IsInstanceOf <NumericRepresentationValue>(actual); Assert.AreEqual(expected, actual.Value.Value, Epsilon); Assert.AreSame(originalUom, actual.Value.UnitOfMeasure); }