public async Task ReaderModel() { using (var con = new SqlConnection(connectionString)) { var sproc = SimulatedSelectStatement.Create(); var cmd = sproc.Build(con); await con.OpenAsync(); var reader = await cmd.ExecuteReaderAsync(); Assert.IsTrue(reader.Read()); var loader = new Loader<SelectData>(); var obj = loader.Model(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, obj.Date.Date); Assert.AreEqual(sproc.TestDateTime.Value.Date, obj.DateTime.Date); Assert.AreEqual(sproc.TestDateTime2.Value.Date, 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.ToString()); Assert.AreEqual(sproc.TestNText, obj.NText); Assert.AreEqual(sproc.TestText, obj.Text); CollectionAssert.AreEqual(sproc.TestBinary, obj.Binary); CollectionAssert.AreEqual(sproc.TestImage, obj.Image); Assert.AreEqual(sproc.TestGuid, obj.Unique); } }
public async Task DataTableModel() { using (var con = new SqlConnection(connectionString)) { var sproc = SimulatedSelectStatement.Create(); var cmd = sproc.Build(con); var loader = new Loader<SelectData>(); await con.OpenAsync(); var adapter = new SqlDataAdapter(cmd); var ds = new DataSet(); adapter.Fill(ds); var table = ds.Tables[0]; var obj = loader.Model(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, obj.Date.Date); Assert.AreEqual(sproc.TestDateTime.Value.Date, obj.DateTime.Date); Assert.AreEqual(sproc.TestDateTime2.Value.Date, 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.ToString()); Assert.AreEqual(sproc.TestNText, obj.NText); Assert.AreEqual(sproc.TestText, obj.Text); CollectionAssert.AreEqual(sproc.TestBinary, obj.Binary); CollectionAssert.AreEqual(sproc.TestImage, obj.Image); Assert.AreEqual(sproc.TestGuid, obj.Unique); } }
public async Task IDbCommandLoadNothing() { var random = new Random(); using (var con = new SqlConnection(connectionString)) { var sproc = new dboSimulatedInsertStatement() { TestInt = random.Next(), }; var cmd = sproc.Build(con); var loader = new Loader<SelectData>(); await con.OpenAsync(); var obj = loader.Model(cmd); Assert.IsNull(obj); } }
public void ModelDataTableNull() { var l = new Loader<object>(); l.Model((DataTable)null); }
public void ModelDataSetNull() { var l = new Loader<object>(); l.Model((DataSet)null); }
public void ModelIDataReaderNull() { var l = new Loader<object>(); l.Model((IDataReader)null); }
public void ModelIDbCommandNull() { var l = new Loader<object>(); l.Model((IDbCommand)null); }