public void ReadWithOneRow()
        {
            DataTable table = new DataTable();

            table.Columns.Add("State", typeof(string));
            table.Rows.Add(new object[] { "TX" });

            TableDataReader reader = new TableDataReader(table);

            // One row, so it should return true the first time, and false the second
            Assert.IsTrue(reader.Read());
            Assert.IsFalse(reader.Read());
        }
        public void ReadWithNoRows()
        {
            DataTable table = new DataTable();

            table.Columns.Add("State", typeof(string));

            TableDataReader reader = new TableDataReader(table);

            // No rows, so it should return false
            Assert.IsFalse(reader.Read());
        }
        public void ReadingAClosedReaderThrowsAnException()
        {
            DataTable table = new DataTable();

            table.Columns.Add("State", typeof(string));
            table.Rows.Add(new object[] { "TX" });
            table.Rows.Add(new object[] { "MO" });
            table.Rows.Add(new object[] { "AR" });

            TableDataReader reader = new TableDataReader(table);

            Assert.IsFalse(reader.IsClosed);
            reader.Close();
            Assert.IsTrue(reader.IsClosed);

            reader.Read();
        }
        public void IsDBNull()
        {
            DataTable table = new DataTable();

            table.Columns.Add("State", typeof(string));
            table.Columns.Add("Direction", typeof(string));
            table.Columns.Add("Count", typeof(int));
            table.Columns.Add("Sum", typeof(int));

            table.Rows.Add(new object[] { DBNull.Value, "North", DBNull.Value, 2 });

            IDataReader reader = new TableDataReader(table);

            reader.Read();

            Assert.IsTrue(reader.IsDBNull(0));
            Assert.IsFalse(reader.IsDBNull(1));
            Assert.IsTrue(reader.IsDBNull(2));
            Assert.IsFalse(reader.IsDBNull(3));
        }
        public void GetValue()
        {
            DataTable table = new DataTable();

            table.Columns.Add("State", typeof(string));
            table.Columns.Add("Direction", typeof(string));
            table.Columns.Add("Count", typeof(int));
            table.Columns.Add("Sum", typeof(int));

            table.Rows.Add(new object[] { "TX", "North", 1, 2 });

            IDataReader reader = new TableDataReader(table);

            reader.Read();

            Assert.AreEqual("TX", (string)reader.GetValue(0));
            Assert.AreEqual("North", (string)reader.GetValue(1));
            Assert.AreEqual(1, (int)reader.GetValue(2));
            Assert.AreEqual(2, (int)reader.GetValue(3));
        }