Пример #1
0
        public void GetSafeNullableStringsFailInvalidFieldName()
        {
            string[] colNames = new string[] { "DBNULL_COL" };
            object[] testData = new object[] { "" };
            string[] expected = new[] { "" };

            IDataReader reader = new DataTableReader(CreateTestDataTable(typeof(string), colNames, testData));

            while (reader.Read())
            {
                Assert.AreEqual(expected[0], reader.GetSafe("NON_EXISTING_COL"));
            }
        }
Пример #2
0
        public void GetSafeInvalidFieldName()
        {
            string[]   colNames = new string[] { "DBNULL_COL" };
            object[]   testData = new object[] { DBNull.Value };
            DateTime[] expected = new DateTime[] { DateTime.MinValue };

            IDataReader reader = new DataTableReader(CreateTestDataTable(typeof(Decimal), colNames, testData));

            // read one record with invalid field name, expected ArgumentOutOfRangeException
            while (reader.Read())
            {
                Assert.AreEqual(expected[0], reader.GetSafe("COLUMN_1", DateTime.MinValue));
            }
        }
Пример #3
0
        public void ParseNullableStringsValue()
        {
            string[] colNames = new string[] { "DBNULL_COL" };
            object[] testData = new object[] { "test ä" };
            string[] expected = new[] { "test ä" };

            IDataReader reader = new DataTableReader(CreateTestDataTable(typeof(string), colNames, testData));

            while (reader.Read())
            {
                Assert.AreEqual(expected[0], Db.Parse(reader, 0));
                Assert.AreEqual(expected[0], reader.GetSafe(0));
            }
        }