public void GivenVariableNumberWhenMultiplyDoubleThenSourceValueIsProduct()
        {
            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.Multiply(1.23);

            Assert.AreEqual(3.62 * 1.23, result.Value.Value, Epsilon);
        }
        public void GivenVariableNumberWithCompositeUnitOfMeasureWhenMultiplyVariableNumberThenCombinedUnitOfMeasure()
        {
            var leftUom   = InternalUnitSystemManager.Instance.UnitOfMeasures["ft1sec-1"].ToModelUom();
            var leftValue = new NumericValue(leftUom, 47.5);
            var left      = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), leftValue);
            var right     = new NumericValue(_ftUnitOfMeasure.ToModelUom(), 3);

            var product = left.Multiply(right);

            Assert.IsInstanceOf <NumericRepresentationValue>(product);
            Assert.AreEqual("ft2sec-1", product.Value.UnitOfMeasure.Code);
            Assert.AreEqual(142.5, product.Value.Value);
        }
        public void GivenVariableNumberWhenMultiplyNumberThenUnitOfMeasuresCombined()
        {
            var uom       = _ftUnitOfMeasure.ToModelUom();
            var leftValue = new NumericValue(uom, 12);
            var left      = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), leftValue);
            var right     = new NumericValue(uom, 4);

            var product = left.Multiply(right);

            Assert.IsInstanceOf <NumericRepresentationValue>(product);
            Assert.AreEqual("ft2", product.Value.UnitOfMeasure.Code);
            Assert.AreEqual(48, product.Value.Value);
        }
        public void GivenVariableNumbersWithTypesThatSimplifyToScalarTypeWhenMultiplyThenShouldHaveScalarUnit()
        {
            var leftUom    = InternalUnitSystemManager.Instance.UnitOfMeasures["ft1sec-1"].ToModelUom();
            var leftValue  = new NumericValue(leftUom, 21.848);
            var left       = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), leftValue);
            var rightUom   = InternalUnitSystemManager.Instance.UnitOfMeasures["sec"].ToModelUom();
            var rightValue = new NumericValue(rightUom, 9.18);
            var right      = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), rightValue);

            var product = left.Multiply(right, RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation());

            Assert.AreEqual("ft", product.Value.UnitOfMeasure.Code);
            //Assert.IsInstanceOf<ScalarUnitOfMeasure>(product.Value.UnitOfMeasure.Scale);??
        }
        public void GivenVariableNumberWithCompositeUnitOfMeasureWhenMultiplyVariableNumberWithCompositeUnitOfMeasureThenCombinedUnitOfMeasure()
        {
            var uom        = InternalUnitSystemManager.Instance.UnitOfMeasures["ft1sec-1"].ToModelUom();
            var leftValue  = new NumericValue(uom, 21.848);
            var left       = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), leftValue);
            var rightValue = new NumericValue(uom, 9.18);
            var right      = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), rightValue);

            var product = left.Multiply(right, RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation());

            Assert.AreSame(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation().Code, product.Representation.Code);
            Assert.AreEqual("ft2[sec2]-1", product.Value.UnitOfMeasure.Code);
            Assert.AreEqual(200.56464, product.Value.Value);
        }
        public void GivenVariableNumberWithCompositeUnitOfMeasureWhenMultiplyVariableNumberWithCompositeUnitOfMeasureThenUnitsCancel()
        {
            var leftUom    = InternalUnitSystemManager.Instance.UnitOfMeasures["ft1sec1"].ToModelUom();
            var leftValue  = new NumericValue(leftUom, 5.15);
            var left       = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), leftValue);
            var rightUom   = InternalUnitSystemManager.Instance.UnitOfMeasures["ft1sec-1"].ToModelUom();
            var rightValue = new NumericValue(rightUom, 7.89);
            var right      = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), rightValue);

            var product = left.Multiply(right, RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation());

            Assert.AreSame(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation().Code, product.Representation.Code);
            Assert.AreEqual("ft2", product.Value.UnitOfMeasure.Code);
            Assert.AreEqual(40.6335, product.Value.Value);
        }
Exemple #7
0
        public static NumericRepresentationValue Multiply(this NumericRepresentationValue numericRepresentationValue, NumericRepresentationValue right, NumericRepresentation numericRepresentation)
        {
            var product = numericRepresentationValue.Multiply(right);

            return(new NumericRepresentationValue(numericRepresentation, product.Value));
        }