public void MatchShouldReturnIndexOfMatchingValue() { var lookupAddress = "A1:A2"; A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName, 1, 1)).Returns(3); A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName, 1, 2)).Returns(5); var result = _parser.Parse("MATCH(3, " + lookupAddress + ")"); Assert.AreEqual(1, result); }
public void HLookupShouldReturnClosestValueBelowIfLastArgIsTrue() { var lookupAddress = "A1:B2"; A.CallTo(() => _excelDataProvider.GetDimensionEnd(A <string> .Ignored)).Returns(new ExcelCellAddress(5, 5)); A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName, 1, 1)).Returns(3); A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName, 1, 2)).Returns(5); A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName, 2, 1)).Returns(1); A.CallTo(() => _excelDataProvider.GetCellValue(WorksheetName, 2, 2)).Returns(2); var result = _parser.Parse("HLOOKUP(4, " + lookupAddress + ", 2, true)"); Assert.AreEqual(1, result); }
private void Initialize() { for (var x = _fromCol; x <= _toCol; x++) { var fieldObj = _dataProvider.GetCellValue(_worksheet, _fieldRow, x); var val = _dataProvider.GetCellValue(_worksheet, _fieldRow + 1, x); if (fieldObj != null && val != null) { if (fieldObj is string) { var field = new ExcelDatabaseCriteriaField(fieldObj.ToString().ToLower(CultureInfo.InvariantCulture)); _criterias.Add(field, val); } else if (ConvertUtil.IsNumeric(fieldObj)) { var field = new ExcelDatabaseCriteriaField((int)fieldObj); _criterias.Add(field, val); } } } }