Exemple #1
0
        public void SmallWithNumericStringInputReturnsPoundNum()
        {
            var function = new Small();
            var result   = function.Execute(FunctionsHelper.CreateArgs("5", "56"), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result.Result).Type);
        }
Exemple #2
0
        public void SmallWithNoInputsReturnsPoundValue()
        {
            var function = new Small();
            var result   = function.Execute(FunctionsHelper.CreateArgs(), this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
Exemple #3
0
        public void SmallShouldReturnTheSecondSmallestNumberIf2()
        {
            var func   = new Small();
            var args   = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(4, 1, 2, 3), 2);
            var result = func.Execute(args, _parsingContext);

            Assert.AreEqual(2d, result.Result);
        }
Exemple #4
0
        public void SmallWithInvalidArgumentReturnsPoundValue()
        {
            var func   = new Small();
            var args   = FunctionsHelper.CreateArgs();
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
Exemple #5
0
        public void SmallShouldReturnTheSmallestNumberIf1()
        {
            var func   = new Small();
            var args   = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(1, 2, 3), 1);
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(1, result.Result);
        }
Exemple #6
0
        public void SmallShouldPoundNumIfIndexOutOfBounds()
        {
            var func   = new Small();
            var args   = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(4, 1, 2, 3), 6);
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(OfficeOpenXml.FormulaParsing.ExpressionGraph.DataType.ExcelError, result.DataType);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)(result.Result)).Type);
        }
Exemple #7
0
        public void SmallWithNullSecondParameterReturnsPoundNum()
        {
            var function = new Small();
            var result   = function.Execute(FunctionsHelper.CreateArgs(5, null), this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result.Result).Type);

            using (var package = new ExcelPackage())
            {
                var worksheet = package.Workbook.Worksheets.Add("Sheet1");
                worksheet.Cells["B1"].Formula = "SMALL(5, )";
                worksheet.Calculate();
                Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)worksheet.Cells["B1"].Value).Type);
            }
        }
Exemple #8
0
 public void SmallShouldThrowIfIndexOutOfBounds()
 {
     var func   = new Small();
     var args   = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(4, 1, 2, 3), 6);
     var result = func.Execute(args, _parsingContext);
 }