public void DynamicDataSetNull() { var l = new DynamicLoader(); l.Dynamic((DataSet)null); }
public void DynamicIDbCommandNull() { var l = new DynamicLoader(); l.Dynamic((IDbCommand)null); }
public async Task DataTableDynamic() { using (var con = new SqlConnection(connectionString)) { var sproc = SimulatedSelectStatement.Create(); var cmd = sproc.Build(con); var loader = new DynamicLoader(); await con.OpenAsync(); var adapter = new SqlDataAdapter(cmd); var ds = new DataSet(); adapter.Fill(ds); var table = ds.Tables[0]; var obj = loader.Dynamic(table); Assert.IsNotNull(obj); Assert.AreEqual(sproc.TestInt, obj.Identifier); Assert.AreEqual(sproc.TestBigInt, obj.BigInt); Assert.AreEqual(sproc.TestBit, obj.Bit); Assert.AreEqual(sproc.TestDate.Value.Date, ((DateTime)obj.Date).Date); Assert.AreEqual(sproc.TestDateTime.Value.Date, ((DateTime)obj.DateTime).Date); Assert.AreEqual(sproc.TestDateTime2.Value.Date, ((DateTime)obj.DateTime2).Date); Assert.AreEqual(sproc.TestDecimal, obj.Decimal); Assert.AreEqual(sproc.TestFloat, obj.Float); Assert.AreEqual(Math.Round((decimal)sproc.TestMoney, 4), obj.Money); Assert.AreEqual(sproc.TestNChar, obj.NChar); Assert.AreEqual(sproc.TestNText, obj.NText); Assert.AreEqual(sproc.TestText, obj.Text); CollectionAssert.AreEqual(sproc.TestBinary, obj.Binary as byte[]); CollectionAssert.AreEqual(sproc.TestImage, obj.Image as byte[]); Assert.AreEqual(sproc.TestGuid, obj.Unique); } }
public void DynamicIDataReaderNull() { var l = new DynamicLoader(); l.Dynamic((IDataReader)null); }
public async Task IDataReaderDynamic() { var loader = new DynamicLoader(); var sproc = SimulatedSelectStatement.Create(); using (var con = new SqlConnection(connectionString)) { var cmd = sproc.Build(con); await con.OpenAsync(); var reader = await cmd.ExecuteReaderAsync(); await reader.ReadAsync(); var obj = loader.Dynamic(reader); Assert.IsNotNull(obj); Assert.AreEqual(sproc.TestInt, obj.Identifier); Assert.AreEqual(sproc.TestBigInt, obj.BigInt); Assert.AreEqual(sproc.TestBit, obj.Bit); Assert.AreEqual(sproc.TestDate.Value.Date, ((DateTime)obj.Date).Date); Assert.AreEqual(sproc.TestDateTime.Value.Date, ((DateTime)obj.DateTime).Date); Assert.AreEqual(sproc.TestDateTime2.Value.Date, ((DateTime)obj.DateTime2).Date); Assert.AreEqual(sproc.TestDecimal, obj.Decimal); Assert.AreEqual(sproc.TestFloat, obj.Float); Assert.AreEqual(Math.Round((decimal)sproc.TestMoney, 4), obj.Money); Assert.AreEqual(sproc.TestNChar, obj.NChar); Assert.AreEqual(sproc.TestNText, obj.NText); Assert.AreEqual(sproc.TestText, obj.Text); CollectionAssert.AreEqual(sproc.TestBinary, obj.Binary as byte[]); CollectionAssert.AreEqual(sproc.TestImage, obj.Image as byte[]); Assert.AreEqual(sproc.TestGuid, obj.Unique); } }