public void AverageIfWithInvalidArgumentReturnsPoundValue() { var func = new AverageIf(); var parsingContext = ParsingContext.Create(); var args = FunctionsHelper.CreateArgs(); var result = func.Execute(args, parsingContext); Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type); }
public void AverageIfNumericExpression() { _worksheet.Cells["A1"].Value = null; _worksheet.Cells["A2"].Value = 1d; _worksheet.Cells["A3"].Value = "Not Empty"; var func = new AverageIf(); IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1); var args = FunctionsHelper.CreateArgs(range, 1d); var result = func.Execute(args, _parsingContext); Assert.AreEqual(1d, result.Result); }
public void AverageIfWithCriteriaAsNumber() { _worksheet.Cells["A1"].Value = null; _worksheet.Cells["A2"].Value = 1d; _worksheet.Cells["A3"].Value = "Not Empty"; IRangeInfo cellsToCompareAndAverage = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1); var function = new AverageIf(); var arguments = FunctionsHelper.CreateArgs(cellsToCompareAndAverage, 1d); var result = function.Execute(arguments, _parsingContext); Assert.AreEqual(1d, result.Result); }
public void AverageIfEqualToEmptyString() { _worksheet.Cells["A1"].Value = null; _worksheet.Cells["A2"].Value = string.Empty; _worksheet.Cells["A3"].Value = "Not Empty"; _worksheet.Cells["B1"].Value = 1d; _worksheet.Cells["B2"].Value = 3d; _worksheet.Cells["B3"].Value = 5d; var func = new AverageIf(); IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1); IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2); var args = FunctionsHelper.CreateArgs(range1, "", range2); var result = func.Execute(args, _parsingContext); Assert.AreEqual(1d, result.Result); }
public void AverageIfNonNumeric() { _worksheet.Cells["A1"].Value = "Monday"; _worksheet.Cells["A2"].Value = "Tuesday"; _worksheet.Cells["A3"].Value = "Thursday"; _worksheet.Cells["B1"].Value = 1d; _worksheet.Cells["B2"].Value = 3d; _worksheet.Cells["B3"].Value = 5d; var func = new AverageIf(); IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1); IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2); var args = FunctionsHelper.CreateArgs(range1, "T*day", range2); var result = func.Execute(args, _parsingContext); Assert.AreEqual(4d, result.Result); }
public void AverageIfWithCriteriaAsLessThanOrEqualToZeroExpression() { _worksheet.Cells["A1"].Value = null; _worksheet.Cells["A2"].Value = string.Empty; _worksheet.Cells["A3"].Value = -1d; _worksheet.Cells["B1"].Value = 1d; _worksheet.Cells["B2"].Value = 3d; _worksheet.Cells["B3"].Value = 5d; IRangeInfo cellsToCompare = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1); IRangeInfo cellsToAverage = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2); var function = new AverageIf(); var arguments = FunctionsHelper.CreateArgs(cellsToCompare, "<=0", cellsToAverage); var result = function.Execute(arguments, _parsingContext); Assert.AreEqual(5d, result.Result); }
public void AverageIfWithNonNumericRangeAndNumericAverageRange() { _worksheet.Cells["A1"].Value = "Monday"; _worksheet.Cells["A2"].Value = "Tuesday"; _worksheet.Cells["A3"].Value = "Thursday"; _worksheet.Cells["B1"].Value = 1d; _worksheet.Cells["B2"].Value = 3d; _worksheet.Cells["B3"].Value = 5d; IRangeInfo cellsToCompare = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1); IRangeInfo cellsToAverage = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2); var function = new AverageIf(); var arguments = FunctionsHelper.CreateArgs(cellsToCompare, "T*day", cellsToAverage); var result = function.Execute(arguments, _parsingContext); Assert.AreEqual(4d, result.Result); }