Esempio n. 1
0
        public static void XTable_All(string configurationLine, int expectedRowCount, string[] requiredColumns = null)
        {
            SampleDatabase.EnsureBuilt();

            int  requiredColumnCount = (requiredColumns == null ? 0 : requiredColumns.Length);
            long actualRowCount;

            using (CancellationTokenSource source = new CancellationTokenSource())
            {
                IXTable           pipeline       = null;
                ValidatingTable   innerValidator = null;
                CancellationToken token          = source.Token;

                try
                {
                    pipeline       = SampleDatabase.XDatabaseContext.Load("WebRequest");
                    innerValidator = new ValidatingTable(pipeline);
                    pipeline       = SampleDatabase.XDatabaseContext.Query(configurationLine, innerValidator);

                    // Run without requesting any columns. Validate.
                    actualRowCount = pipeline.RunWithoutDispose(token).RowCount;
                    Assert.AreEqual(expectedRowCount, actualRowCount, "XTable should return correct count with no requested columns.");

                    // Reset; Request all columns. Validate.
                    pipeline.Reset();
                    pipeline       = SampleDatabase.XDatabaseContext.Query("write \"Sample.output.csv\"", pipeline);
                    actualRowCount = pipeline.RunWithoutDispose(token).RowCount;
                }
                finally
                {
                    if (pipeline != null)
                    {
                        pipeline.Dispose();
                        pipeline = null;

                        if (innerValidator != null)
                        {
                            Assert.IsTrue(innerValidator.DisposeCalled, "Source must call Dispose on nested sources.");
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public ValidatingColumn(ValidatingTable table, IXColumn column)
 {
     _table  = table;
     _column = column;
 }