示例#1
0
        public void MedianWithNumericStringInputReturnsCorrectValue()
        {
            var function = new Median();
            var result   = function.Execute(FunctionsHelper.CreateArgs("16", "55", "19", "20"), this.ParsingContext);

            Assert.AreEqual(19.5d, result.Result);
        }
示例#2
0
        public void MedianShouldThrowIfNoArgs()
        {
            var func = new Median();
            var args = FunctionsHelper.Empty();

            func.Execute(args, _parsingContext);
        }
示例#3
0
        public void MedianWithNumericInputsReturnsCorrectValue()
        {
            var function = new Median();
            var result   = function.Execute(FunctionsHelper.CreateArgs(16, 55, 19, 20), this.ParsingContext);

            Assert.AreEqual(19.5d, result.Result);
        }
示例#4
0
        public void MedianWithGenericStringInputReturnsPoundValue()
        {
            var function = new Median();
            var result   = function.Execute(FunctionsHelper.CreateArgs("string", "string", "string"), this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
示例#5
0
        public void MedianWithOneInputReturnsCorrectValue()
        {
            var function = new Median();
            var result   = function.Execute(FunctionsHelper.CreateArgs(15), this.ParsingContext);

            Assert.AreEqual(15d, result.Result);
        }
示例#6
0
        public void MedianWithDoubleInputsReturnsCorrectValue()
        {
            var function = new Median();
            var result   = function.Execute(FunctionsHelper.CreateArgs(5.5, 2.3, 15.6, 11.2), this.ParsingContext);

            Assert.AreEqual(8.35d, result.Result);
        }
示例#7
0
        public void MedianWithLogicInputsReturnsCorrectValue()
        {
            var function = new Median();
            var result   = function.Execute(FunctionsHelper.CreateArgs(true, false), this.ParsingContext);

            Assert.AreEqual(0.5d, result.Result);
        }
示例#8
0
        public void MedianShouldCalculateCorrectlyWithEvenMembers()
        {
            var func   = new Median();
            var args   = FunctionsHelper.CreateArgs(1, 2, 3, 4);
            var result = func.Execute(args, _parsingContext);

            Assert.AreEqual(2.5d, result.Result);
        }
示例#9
0
        public void MedianShouldCalculateCorrectlyWithOddMembers()
        {
            var function  = new Median();
            var arguments = FunctionsHelper.CreateArgs(3, 5, 1, 4, 2);
            var result    = function.Execute(arguments, this.ParsingContext);

            Assert.AreEqual(3d, result.Result);
        }
示例#10
0
        public void MedianShouldPoundNumIfNoArgs()
        {
            var function  = new Median();
            var arguments = new FunctionArgument[] { new FunctionArgument(null) };
            var result    = function.Execute(arguments, this.ParsingContext);

            Assert.AreEqual(OfficeOpenXml.FormulaParsing.ExpressionGraph.DataType.ExcelError, result.DataType);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)(result.Result)).Type);
        }