Example #1
0
        public void NumberValueShouldCastIntegerValue()
        {
            var func   = new NumberValue();
            var result = func.Execute(FunctionsHelper.CreateArgs("1000"), _parsingContext);

            Assert.AreEqual(1000d, result.Result);
        }
Example #2
0
        public void NumberValueShouldHandlePercentage()
        {
            var input  = $"1,000.15%";
            var func   = new NumberValue();
            var result = func.Execute(FunctionsHelper.CreateArgs(input, ".", ","), _parsingContext);

            Assert.AreEqual(10.0015d, result.Result);
        }
Example #3
0
        public void NumberValueShouldCastDecinalValueWithSeparators()
        {
            var input  = $"1,000.15";
            var func   = new NumberValue();
            var result = func.Execute(FunctionsHelper.CreateArgs(input, ".", ","), _parsingContext);

            Assert.AreEqual(1000.15d, result.Result);
        }
Example #4
0
        public void NumberValueShouldCastDecinalValueWithCurrentCulture()
        {
            var input  = $"1{CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator}000{CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator}15";
            var func   = new NumberValue();
            var result = func.Execute(FunctionsHelper.CreateArgs(input), _parsingContext);

            Assert.AreEqual(1000.15d, result.Result);
        }
Example #5
0
        public void NumberValueShouldHandleMultiplePercentage()
        {
            var input  = $"1,000.15%%";
            var func   = new NumberValue();
            var result = func.Execute(FunctionsHelper.CreateArgs(input, ".", ","), _parsingContext);
            var r      = System.Math.Round((double)result.Result, 15);

            Assert.AreEqual(0.100015d, r);
        }