public static void TestDataSet3DVariable(string tableName, LookupColumn3dTest lookupColumn3dTest, LookupColumnTest lookupColumnTest, Variable v)
        {
            var columnTest = lookupColumnTest.Invoke(v.Name);

            if (columnTest.Include)
            {
                ColumnTest.TestDataSetVariable(tableName, lookupColumnTest, v);
            }
            else
            {
                var column3dTest = lookupColumn3dTest.Invoke(v.Name);
                if (column3dTest.Include)
                {
                    var actualTruncated = (double[, , ])null;

                    switch (v.TypeOfData.Name.ToString().ToLower())
                    {
                    case "double":
                    {
                        var actual = (double[, , ])v.GetData();
                        var count1 = column3dTest.Expected.GetLength(0);
                        var count2 = column3dTest.Expected.GetLength(1);
                        var count3 = column3dTest.Expected.GetLength(2);

                        actualTruncated = new double[count1, count2, count3];

                        for (var ii = 0; ii < count1; ii++)
                        {
                            for (var jj = 0; jj < count2; jj++)
                            {
                                for (var kk = 0; kk < count3; kk++)
                                {
                                    actualTruncated[ii, jj, kk] = actual[ii, jj, kk];
                                }
                            }
                        }
                    }
                    break;

                    default:
                        throw new Exception("unexpected column type");
                    }

                    DoColumn3dTest(column3dTest, actualTruncated);
                }
                else
                {
                    Console.WriteLine("Skipping : {0}", v.Name);
                }
            }
        }
        public static void DoColumnTest(string tableName, string columnName, ColumnTest columnTest, double[] actual)
        {
#if DEBUG_COMPARISON
            Func<double, double, bool> test = columnTest.Tolerance != null ?
                (Func<double, double, bool>)((a, e) => columnTest.Tolerance.Equals(a, e)) :
                (Func<double, double, bool>)((a, e) => a.Equals(e));

            var tests = actual.Zip(columnTest.Expected, (a, e) => Tuple.Create(a, e, test(a, e)));

            Assert.IsTrue(tests.All(match => match.Item3), String.Format("Table: {0}, Column: {1}, Tests: {2}", tableName, columnName, Common.FormatTests(tests)));
#else
            if (columnTest.Tolerance != null)
            {
                Assert.That(actual.SequenceEqual(columnTest.Expected, columnTest.Tolerance));
            }
            else
            {
                Assert.That(actual, Is.EquivalentTo(columnTest.Expected));
            }
#endif
        }
Exemple #3
0
        public static void DoColumnTest(string tableName, string columnName, ColumnTest columnTest, double[] actual)
        {
#if DEBUG_COMPARISON
            Func <double, double, bool> test = columnTest.Tolerance != null ?
                                               (Func <double, double, bool>)((a, e) => columnTest.Tolerance.Equals(a, e)) :
                                               (Func <double, double, bool>)((a, e) => a.Equals(e));

            var tests = actual.Zip(columnTest.Expected, (a, e) => Tuple.Create(a, e, test(a, e)));

            Assert.IsTrue(tests.All(match => match.Item3), String.Format("Table: {0}, Column: {1}, Tests: {2}", tableName, columnName, Common.FormatTests(tests)));
#else
            if (columnTest.Tolerance != null)
            {
                Assert.That(actual.SequenceEqual(columnTest.Expected, columnTest.Tolerance));
            }
            else
            {
                Assert.That(actual, Is.EquivalentTo(columnTest.Expected));
            }
#endif
        }