Exemplo n.º 1
0
        public void Can_read_table_with_string_column()
        {
            var table = new DataTable();

            table.Columns.Add("String Column");
            DataRow row1 = table.NewRow();
            DataRow row2 = table.NewRow();

            row1["String Column"] = "First String";
            row2["String Column"] = "Second String";

            table.Rows.Add(row1);
            table.Rows.Add(row2);

            IDataTableReader tableReader = new DataTableReader();

            tableReader.Open(table);

            Assert.That(tableReader.Read(), Is.EqualTo(true));
            Assert.That(tableReader.GetString("String Column"), Is.EqualTo("First String"));

            Assert.That(tableReader.Read(), Is.EqualTo(true));
            Assert.That(tableReader.GetString("String Column"), Is.EqualTo("Second String"));

            Assert.That(tableReader.Read(), Is.EqualTo(false));
        }
Exemplo n.º 2
0
        public void Returns_null_for_an_empty_string_value()
        {
            var table = new DataTable();

            table.Columns.Add("String Column");
            table.Columns.Add("Decimal Column");
            DataRow row1 = table.NewRow();

            row1["String Column"]  = string.Empty;
            row1["Decimal Column"] = 5.5M;

            table.Rows.Add(row1);

            IDataTableReader tableReader = new DataTableReader();

            tableReader.Open(table);

            Assert.That(tableReader.Read(), Is.EqualTo(true));
            Assert.That(tableReader.GetString("String Column"), Is.Null);
            Assert.That(tableReader.GetDecimal("Decimal Column"), Is.EqualTo(5.5M));

            Assert.That(tableReader.Read(), Is.EqualTo(false));
        }
		public void Returns_null_for_an_empty_string_value()
		{
			var table = new DataTable();
			table.Columns.Add("String Column");
			table.Columns.Add("Decimal Column");
			DataRow row1 = table.NewRow();

			row1["String Column"] = string.Empty;
			row1["Decimal Column"] = 5.5M;

			table.Rows.Add(row1);

			IDataTableReader tableReader = new DataTableReader();

			tableReader.Open(table);

			Assert.That(tableReader.Read(), Is.EqualTo(true));
			Assert.That(tableReader.GetString("String Column"), Is.Null);
			Assert.That(tableReader.GetDecimal("Decimal Column"), Is.EqualTo(5.5M));

			Assert.That(tableReader.Read(), Is.EqualTo(false));
		}
		public void Can_read_table_with_string_column()
		{
			var table = new DataTable();
			table.Columns.Add("String Column");
			DataRow row1 = table.NewRow();
			DataRow row2 = table.NewRow();

			row1["String Column"] = "First String";
			row2["String Column"] = "Second String";

			table.Rows.Add(row1);
			table.Rows.Add(row2);

			IDataTableReader tableReader = new DataTableReader();

			tableReader.Open(table);

			Assert.That(tableReader.Read(), Is.EqualTo(true));
			Assert.That(tableReader.GetString("String Column"), Is.EqualTo("First String"));

			Assert.That(tableReader.Read(), Is.EqualTo(true));
			Assert.That(tableReader.GetString("String Column"), Is.EqualTo("Second String"));

			Assert.That(tableReader.Read(), Is.EqualTo(false));
		}