Exemple #1
0
        public void Should_be_able_to_map_from_a_data_record()
        {
            var record = new SqlDataRecord(new[] { new SqlMetaData("column-1", SqlDbType.VarChar, 65) });

            record.SetSqlString(0, new SqlString(null));

            var column1 = new MappedColumn <string>("column-1", DbType.AnsiString, 65);
            var column2 = new MappedColumn <string>("column-2", DbType.AnsiString, 65);

            Assert.AreEqual(default(string), column1.MapFrom(record));
            Assert.AreEqual(default(string), column2.MapFrom(record));

            record.SetSqlString(0, new SqlString("value-1"));

            Assert.AreEqual("value-1", column1.MapFrom(record));
            Assert.AreEqual(default(string), column2.MapFrom(record));
        }
Exemple #2
0
        public void Should_be_able_to_map_from_a_data_row()
        {
            var table = new DataTable();

            table.Columns.Add("column-1", typeof(string));

            var row = table.Rows.Add(DBNull.Value);

            var mc      = new MappedColumn <string>("column-1", DbType.AnsiString, 65);
            var missing = new MappedColumn <string>("missing", DbType.AnsiString, 65);

            Assert.AreEqual(default(string), mc.MapFrom(row));
            Assert.AreEqual(default(string), missing.MapFrom(row));
            Assert.AreEqual(DBNull.Value, mc.RetrieveRawValueFrom(row));

            row["column-1"] = "value-1";

            Assert.AreEqual("value-1", mc.MapFrom(row));
            Assert.AreEqual(default(string), missing.MapFrom(row));
            Assert.AreEqual("value-1", mc.RetrieveRawValueFrom(row));
        }
        public void Should_be_able_to_map_from_a_data_row()
        {
            var table = new DataTable();

            table.Columns.Add("column-1", typeof(string));

            var row = table.Rows.Add(DBNull.Value);

            var mc = new MappedColumn<string>("column-1", DbType.AnsiString, 65);
            var missing = new MappedColumn<string>("missing", DbType.AnsiString, 65);

            Assert.AreEqual(default(string), mc.MapFrom(row));
            Assert.AreEqual(default(string), missing.MapFrom(row));
            Assert.AreEqual(DBNull.Value, mc.RetrieveRawValueFrom(row));

            row["column-1"] = "value-1";

            Assert.AreEqual("value-1", mc.MapFrom(row));
            Assert.AreEqual(default(string), missing.MapFrom(row));
            Assert.AreEqual("value-1", mc.RetrieveRawValueFrom(row));
        }
        public void Should_be_able_to_map_from_a_data_record()
        {
            var record = new SqlDataRecord(new[] { new SqlMetaData("column-1", SqlDbType.VarChar, 65) });

            record.SetSqlString(0, new SqlString(null));

            var column1 = new MappedColumn<string>("column-1", DbType.AnsiString, 65);
            var column2 = new MappedColumn<string>("column-2", DbType.AnsiString, 65);

            Assert.AreEqual(default(string), column1.MapFrom(record));
            Assert.AreEqual(default(string), column2.MapFrom(record));

            record.SetSqlString(0, new SqlString("value-1"));

            Assert.AreEqual("value-1", column1.MapFrom(record));
            Assert.AreEqual(default(string), column2.MapFrom(record));
        }