private static void ConfirmExpectedResult(String msg, ICell expected, CellValue actual) { if (expected == null) { throw new AssertionException(msg + " - Bad Setup data expected value is null"); } if (actual == null) { throw new AssertionException(msg + " - actual value was null"); } switch (expected.CellType) { case CellType.Blank: Assert.AreEqual(CellType.Blank, actual.CellType, msg); break; case CellType.Boolean: Assert.AreEqual(CellType.Boolean, actual.CellType); Assert.AreEqual(expected.BooleanCellValue, actual.BooleanValue, msg); break; case CellType.Error: Assert.AreEqual(CellType.Error, actual.CellType, msg); if (false) { // TODO: fix ~45 functions which are currently returning incorrect error values Assert.AreEqual(expected.ErrorCellValue, actual.ErrorValue, msg); } break; case CellType.Formula: // will never be used, since we will call method After formula Evaluation throw new AssertionException("Cannot expect formula as result of formula Evaluation: " + msg); case CellType.Numeric: Assert.AreEqual(CellType.Numeric, actual.CellType, msg); TestMathX.AssertEquals(msg, expected.NumericCellValue, actual.NumberValue, TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); // double delta = Math.Abs(expected.NumericCellValue-actual.NumberValue); // double pctExpected = Math.Abs(0.00001*expected.NumericCellValue); // Assert.IsTrue(msg, delta <= pctExpected); break; case CellType.String: Assert.AreEqual(CellType.String, actual.CellType, msg); Assert.AreEqual(expected.RichStringCellValue.String, actual.StringValue, msg); break; } }
private static void ConfirmExpectedResult(string msg, ICell expected, CellValue actual) { if (expected == null) { throw new AssertFailedException(msg + " - Bad Setup data expected value is null"); } if (actual == null) { throw new AssertFailedException(msg + " - actual value was null"); } switch (expected.CellType) { case CellType.Blank: Assert.AreEqual(CellType.Blank, actual.CellType, msg); break; case CellType.Boolean: Assert.AreEqual(CellType.Boolean, actual.CellType, msg); Assert.AreEqual(expected.BooleanCellValue, actual.BooleanValue, msg); break; case CellType.Error: Assert.AreEqual(CellType.Error, actual.CellType, msg); Assert.AreEqual(msg, ErrorEval.GetText(expected.ErrorCellValue), ErrorEval.GetText(actual.ErrorValue)); break; case CellType.Formula: // will never be used, since we will call method After formula Evaluation throw new AssertFailedException("Cannot expect formula as result of formula Evaluation: " + msg); case CellType.Numeric: Assert.AreEqual(CellType.Numeric, actual.CellType, msg); TestMathX.AssertEquals(msg, expected.NumericCellValue, actual.NumberValue, TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); break; case CellType.String: Assert.AreEqual(CellType.String, actual.CellType, msg); Assert.AreEqual(msg, expected.RichStringCellValue.String, actual.StringValue); break; } }