public void KeepColumnsRemove()
        {
            MutableDataTable dt = GetTable();

            dt.KeepColumns("last");

            AnalyzeTests.AssertEquals(
                @"last
Smith
Jones
", dt);
        }
        public void KeepColumnsReorder()
        {
            MutableDataTable dt = GetTable();

            dt.KeepColumns("last", "first");

            AnalyzeTests.AssertEquals(
                @"last,first
Smith,Bob
Jones,Fred
", dt);
        }
        public void KeepColumnsDoNotThrow()
        {
            MutableDataTable dt = GetTable();

            dt.KeepColumns(false, "last", "first", "made up column name");

            AnalyzeTests.AssertEquals(
                @"last,first
Smith,Bob
Jones,Fred
", dt);
        }
        public void KeepColumnsThrowOnMissing()
        {
            MutableDataTable dt = GetTable();

            bool wasErrorThrown = false;

            try
            {
                dt.KeepColumns(true, "last", "first", "made up column name");
            }
            catch (InvalidOperationException)
            {
                wasErrorThrown = true;
            }

            Assert.True(wasErrorThrown);
            // not testing contents of the table since we are assuming that an Exception was thrown
        }
Exemple #5
0
        public void UploadCsvToAzureTables()
        {
            // Save a table to azure, and then use traditional techniques to query it back.
            // Use a large enough value to forcve batching and spilling.
            var account = GetStorage();

            var       source   = from x in Enumerable.Range(1, 200) select new { N = x, N2 = x * x };
            DataTable dtSource = DataTable.New.FromEnumerable(source);

            string tableName = "csvtesttable";

            dtSource.SaveToAzureTable(account, tableName);

            // Use traditional Azure table read to verify the newly uploaded table matches source.
            TestRecord[] result = Utility.ReadTable <TestRecord>(account, tableName);
            int          i      = 0;

            foreach (var item in source)
            {
                Assert.Equal(item.N, result[i].N);
                Assert.Equal(item.N2, result[i].N2);
                i++;
            }
            Assert.Equal(i, result.Length);

            // Read back as datatable
            DataTable dtFromAzure = DataTable.New.ReadAzureTableLazy(account, tableName);

            // When reading from Azure, we should get back row, parition, and timestamp keys.
            Assert.True(dtFromAzure.HasColumnName("RowKey"));
            Assert.True(dtFromAzure.HasColumnName("PartitionKey"));
            Assert.True(dtFromAzure.HasColumnName("TimeStamp"));

            // Compare contents with original table that was uploaded. Easy way to do this is to just keep the original columns.
            MutableDataTable dt5 = DataTable.New.GetMutableCopy(dtFromAzure);

            dt5.KeepColumns("N", "N2");
            Utility.AssertEquals(dtSource, dt5);
        }
        public void KeepColumnsBadNameRemove()
        {
            MutableDataTable dt = GetTable();

            Assert.Throws <InvalidOperationException>(() => dt.KeepColumns("missing"));
        }