public void GivenVariableNumberWhenAddDoubleShouldReturnNewVariableNumberWithSourceAddedToDouble()
        {
            var uom           = InternalUnitSystemManager.Instance.UnitOfMeasures["mi"].ToModelUom();
            var originalValue = new NumericValue(uom, 3.62);
            var number        = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), originalValue);

            var result = number.Add(1.23);

            Assert.IsInstanceOf <NumericRepresentationValue>(result);
            Assert.AreEqual(4.85, result.Value.Value, Epsilon);
        }
        public void GivenTwoVariableNumbersWithSameUomWhenAddedThenSourceValueIsSum()
        {
            var uom           = InternalUnitSystemManager.Instance.UnitOfMeasures["C"].ToModelUom();
            var originalValue = new NumericValue(uom, 22);
            var originalRep   = new NumericRepresentationValue(RepresentationInstanceList.vrAirTemperature.ToModelRepresentation(), originalValue);
            var secondNumber  = new NumericValue(uom, 11);

            var result = originalRep.Add(secondNumber);

            Assert.IsInstanceOf <NumericRepresentationValue>(result);
            Assert.AreEqual(33, result.Value.Value);
        }
        public void GivenVariableNumbersWithIncompatibleUnitsWhenAddThenException()
        {
            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.Add(secondNumber));
        }
        public void GivenTwoVariableNumbersWhenAddedThenRepresentationIsOriginal()
        {
            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.Add(secondNumber);

            Assert.AreSame(RepresentationInstanceList.vrDistanceTraveled.DomainId, result.Representation.Code);
        }
        public void GivenVariableNumberWhenAddVariableNumberThenResultIsInOriginalUom()
        {
            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 = 2.8168; //1.75m + (3.5ft -> m)
            var actual   = originalNumber.Add(secondNumber);

            Assert.IsInstanceOf <NumericRepresentationValue>(actual);
            Assert.AreEqual(expected, actual.Value.Value, 0.005);
            Assert.AreSame(originalUom, actual.Value.UnitOfMeasure);
        }