예제 #1
0
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }