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

            Assert.Throws <DivideByZeroException>(() => number.Divide(0));
        }
        public void GivenVariableNumberWhenDivideVariableNumberWithZeroValueThenDivideByZeroException()
        {
            var numeratorUom     = _ftUnitOfMeasure.ToModelUom();
            var numeratorValue   = new NumericValue(numeratorUom, 3);
            var numerator        = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), numeratorValue);
            var denominatorUom   = InternalUnitSystemManager.Instance.UnitOfMeasures["sec"].ToModelUom();
            var denominatorValue = new NumericValue(denominatorUom, 0);
            var denominator      = new NumericRepresentationValue(RepresentationInstanceList.vrDeltaTime.ToModelRepresentation(), denominatorValue);

            Assert.Throws <DivideByZeroException>(() => numerator.Divide(denominator, RepresentationInstanceList.vrVehicleSpeed.ToModelRepresentation()));
        }
        public void GivenVariableNumberWhenDivideDoubleThenSourceValueIsQuotient()
        {
            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.Divide(1.23);

            Assert.IsInstanceOf <NumericRepresentationValue>(result);
            Assert.AreEqual(3.62 / 1.23, result.Value.Value, Epsilon);
        }
        public void GivenVariableNumberWhenDivideNumberWithSameUnitThenSourceValueIsQuotient()
        {
            var uom         = _ftUnitOfMeasure.ToModelUom();
            var value       = new NumericValue(uom, 12);
            var numerator   = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), value);
            var denominator = new NumericValue(_ftUnitOfMeasure.ToModelUom(), 6);

            var quotient = numerator.Divide(denominator);

            Assert.IsInstanceOf <NumericRepresentationValue>(quotient);
            Assert.AreEqual("ratio", quotient.Value.UnitOfMeasure.Code);
            Assert.AreEqual(2, quotient.Value.Value, Epsilon);
        }
        public void GivenVariableNumberWhenDivideVariableNumberThenUnitOfMeasuresCombined()
        {
            var uom         = _ftUnitOfMeasure.ToModelUom();
            var value       = new NumericValue(uom, 12);
            var numerator   = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), value);
            var denominator = new NumericValue(InternalUnitSystemManager.Instance.UnitOfMeasures["sec"].ToModelUom(), 5);

            var quotient = numerator.Divide(denominator);

            Assert.IsInstanceOf <NumericRepresentationValue>(quotient);
            Assert.AreEqual("ft1sec-1", quotient.Value.UnitOfMeasure.Code);
            Assert.AreEqual(2.4, quotient.Value.Value, Epsilon);
        }
        public void GivenVariableNumberWithCompositeUnitOfMeasureWhenDivdeVariableNumberWithCompositeUnitOfMeasureThenUnitOfMeasuresSimplified()
        {
            var numeratorUom     = InternalUnitSystemManager.Instance.UnitOfMeasures["ft1sec-1"].ToModelUom();
            var numeratorValue   = new NumericValue(numeratorUom, 52.15);
            var numerator        = new NumericRepresentationValue(RepresentationInstanceList.vrEngineSpeed.ToModelRepresentation(), numeratorValue);
            var denominatorUom   = InternalUnitSystemManager.Instance.UnitOfMeasures["gal1sec-1"].ToModelUom();
            var denominatorValue = new NumericValue(denominatorUom, 12);
            var denominator      = new NumericRepresentationValue(RepresentationInstanceList.vrFuelRatePerHour.ToModelRepresentation(), denominatorValue);

            var quotient = numerator.Divide(denominator, RepresentationInstanceList.vrEngineSpeed.ToModelRepresentation());

            Assert.AreEqual("ft1gal-1", quotient.Value.UnitOfMeasure.Code);
            Assert.AreSame(RepresentationInstanceList.vrEngineSpeed.ToModelRepresentation().Code, quotient.Representation.Code);
            Assert.AreEqual(4.345833333333333, quotient.Value.Value, Epsilon);
        }
        public void GivenVariableNumberWhenWhenDivideVariableNumberWithCompositeUnitOfMeasureThenUnitOfMeasuresSimplified()
        {
            var numeratorUom     = _ftUnitOfMeasure.ToModelUom();
            var numeratorValue   = new NumericValue(numeratorUom, 12.54);
            var numerator        = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), numeratorValue);
            var denominatorUom   = InternalUnitSystemManager.Instance.UnitOfMeasures["[sec2]-1"].ToModelUom();
            var denominatorValue = new NumericValue(denominatorUom, 5);
            var denominator      = new NumericRepresentationValue(RepresentationInstanceList.vrDeltaTime.ToModelRepresentation(), denominatorValue);

            var quotient = numerator.Divide(denominator, RepresentationInstanceList.vrDeltaTime.ToModelRepresentation());

            Assert.AreEqual("ft1sec2", quotient.Value.UnitOfMeasure.Code);
            Assert.AreSame(RepresentationInstanceList.vrDeltaTime.ToModelRepresentation().Code, quotient.Representation.Code);
            Assert.AreEqual(2.508, quotient.Value.Value, Epsilon);
        }