Beispiel #1
0
        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, msg);
                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);
                AbstractNumericTestCase.AssertEqual(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;
            }
        }
Beispiel #2
0
        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, msg);
                Assert.AreEqual(expected.BooleanCellValue, actual.BooleanValue, msg);
                break;

            case CellType.ERROR:
                Assert.AreEqual(CellType.ERROR, actual.CellType, msg);
                Assert.AreEqual(ErrorEval.GetText(expected.ErrorCellValue), ErrorEval.GetText(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);
                AbstractNumericTestCase.AssertEqual(msg, expected.NumericCellValue, actual.NumberValue,
                                                    AbstractNumericTestCase.POS_ZERO, AbstractNumericTestCase.DIFF_TOLERANCE_FACTOR);
                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)
        {
            Assert.IsNotNull(expected, msg + " - Bad setup data expected value is null");
            Assert.IsNotNull(actual, 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(ErrorEval.GetText(expected.ErrorCellValue), ErrorEval.GetText(actual.ErrorValue), msg);
                break;

            case CellType.Formula:     // will never be used, since we will call method After formula Evaluation
                Assert.Fail("Cannot expect formula as result of formula Evaluation: " + msg);
                break;

            case CellType.Numeric:
                Assert.AreEqual(CellType.Numeric, actual.CellType, msg);
                AbstractNumericTestCase.AssertEquals(msg, expected.NumericCellValue, actual.NumberValue,
                                                     AbstractNumericTestCase.POS_ZERO, AbstractNumericTestCase.DIFF_TOLERANCE_FACTOR);
                break;

            case CellType.String:
                Assert.AreEqual(CellType.String, actual.CellType, msg);
                Assert.AreEqual(expected.RichStringCellValue.String, actual.StringValue, msg);
                break;
            }
        }