public void MatchShouldReturnIndexOfMatchingValVertical_MatchTypeExact() { var func = new Match(); var args = FunctionsHelper.CreateArgs(3, "A1:A3", 0); var parsingContext = ParsingContext.Create(); var provider = MockRepository.GenerateStub<ExcelDataProvider>(); provider.Stub(x => x.GetCellValue(0, 0)).Return(new ExcelCell(1, null, 0, 0)); provider.Stub(x => x.GetCellValue(1, 0)).Return(new ExcelCell(3, null, 0, 0)); provider.Stub(x => x.GetCellValue(2, 0)).Return(new ExcelCell(5, null, 0, 0)); parsingContext.ExcelDataProvider = provider; var result = func.Execute(args, parsingContext); Assert.AreEqual(2, result.Result); }
public BuiltInFunctions() { // Text Functions["text"] = new CStr(); Functions["len"] = new Len(); Functions["lower"] = new Lower(); Functions["upper"] = new Upper(); Functions["left"] = new Left(); Functions["right"] = new Right(); Functions["mid"] = new Mid(); Functions["replace"] = new Replace(); Functions["substitute"] = new Substitute(); Functions["concatenate"] = new Concatenate(); // Numbers Functions["int"] = new CInt(); // Math Functions["cos"] = new Cos(); Functions["cosh"] = new Cosh(); Functions["power"] = new Power(); Functions["sqrt"] = new Sqrt(); Functions["sqrtpi"] = new SqrtPi(); Functions["pi"] = new Pi(); Functions["product"] = new Product(); Functions["ceiling"] = new Ceiling(); Functions["count"] = new Count(); Functions["counta"] = new CountA(); Functions["floor"] = new Floor(); Functions["sin"] = new Sin(); Functions["sinh"] = new Sinh(); Functions["sum"] = new Sum(); Functions["sumif"] = new SumIf(); Functions["stdev"] = new Stdev(); Functions["stdevp"] = new StdevP(); Functions["subtotal"] = new Subtotal(); Functions["exp"] = new Exp(); Functions["log"] = new Log(); Functions["log10"] = new Log10(); Functions["max"] = new Max(); Functions["maxa"] = new Maxa(); Functions["min"] = new Min(); Functions["mod"] = new Mod(); Functions["average"] = new Average(); Functions["round"] = new Round(); Functions["rand"] = new Rand(); Functions["randbetween"] = new RandBetween(); Functions["tan"] = new Tan(); Functions["tanh"] = new Tanh(); Functions["var"] = new Var(); Functions["varp"] = new VarP(); // Information Functions["isblank"] = new IsBlank(); Functions["isnumber"] = new IsNumber(); Functions["istext"] = new IsText(); Functions["iserror"] = new IsError(); // Logical Functions["if"] = new If(); Functions["not"] = new Not(); Functions["and"] = new And(); Functions["or"] = new Or(); Functions["true"] = new True(); // Reference and lookup Functions["address"] = new Address(); Functions["hlookup"] = new HLookup(); Functions["vlookup"] = new VLookup(); Functions["lookup"] = new Lookup(); Functions["match"] = new Match(); Functions["row"] = new Row(); Functions["rows"] = new Rows(); Functions["column"] = new Column(); Functions["columns"] = new Columns(); Functions["choose"] = new Choose(); // Date Functions["date"] = new Date(); Functions["today"] = new Today(); Functions["now"] = new Now(); Functions["day"] = new Day(); Functions["month"] = new Month(); Functions["year"] = new Year(); Functions["time"] = new Time(); Functions["hour"] = new Hour(); Functions["minute"] = new Minute(); Functions["second"] = new Second(); }
public void MatchShouldReturnIndexOfMatchingValHorizontal_MatchTypeClosestAbove() { var func = new Match(); var args = FunctionsHelper.CreateArgs(6, "A1:C1", -1); var parsingContext = ParsingContext.Create(); var provider = MockRepository.GenerateStub<ExcelDataProvider>(); provider.Stub(x => x.GetCellValue(0, 0)).Return(new ExcelCell(10, null, 0, 0)); provider.Stub(x => x.GetCellValue(0, 1)).Return(new ExcelCell(8, null, 0, 0)); provider.Stub(x => x.GetCellValue(0, 2)).Return(new ExcelCell(5, null, 0, 0)); parsingContext.ExcelDataProvider = provider; var result = func.Execute(args, parsingContext); Assert.AreEqual(2, result.Result); }