Exemplo n.º 1
0
        public async Task DataTableDictionaries()
        {
            using (var con = new SqlConnection(connectionString))
            {
                var sproc = new dboSelectMultipleStatement();

                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 objs = loader.Dictionaries(ds.Tables[0]);

                Assert.IsNotNull(objs);

                var i = 0;
                foreach (var obj in objs)
                {
                    Assert.AreEqual(i, obj["Identifier"]);
                    i++;
                }
            }
        }
Exemplo n.º 2
0
        public async Task DataTableDictionary()
        {
            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.Dictionary(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"]);
            }
        }
Exemplo n.º 3
0
 public void DynamicDataSetNull()
 {
     var l = new DynamicLoader();
     l.Dynamic((DataSet)null);
 }
Exemplo n.º 4
0
 public void DictionariesIDataReaderNull()
 {
     var l = new DynamicLoader();
     l.Dictionaries((IDataReader)null);
 }
Exemplo n.º 5
0
 public void DictionariesDataSetNull()
 {
     var l = new DynamicLoader();
     l.Dictionaries((DataSet)null);
 }
Exemplo n.º 6
0
 public void DictionaryDataTableNull()
 {
     var l = new DynamicLoader();
     l.Dictionary((DataTable)null);
 }
Exemplo n.º 7
0
 public void DynamicIDbCommandNull()
 {
     var l = new DynamicLoader();
     l.Dynamic((IDbCommand)null);
 }
Exemplo n.º 8
0
 public void DictionaryIDbCommandNull()
 {
     var l = new DynamicLoader();
     l.Dictionary((IDbCommand)null);
 }
Exemplo n.º 9
0
 public void DynamicsIDataReaderNull()
 {
     var l = new DynamicLoader();
     l.Dynamics((IDataReader)null);
 }
Exemplo n.º 10
0
        public async Task IDbCommandDynamics()
        {
            var sproc = new dboSelectMultipleStatement();
            var loader = new DynamicLoader();

            using (var con = new SqlConnection(connectionString))
            {
                var cmd = sproc.Build(con);

                await con.OpenAsync();
                var objs = loader.Dynamics(cmd);

                Assert.IsNotNull(objs);

                var i = 0;
                foreach (var obj in objs)
                {
                    Assert.AreEqual(i, obj.Identifier);
                    i++;
                }
            }
        }
Exemplo n.º 11
0
        public async Task IDbCommandDynamic()
        {
            var loader = new DynamicLoader();
            var sproc = SimulatedSelectStatement.Create();

            using (var con = new SqlConnection(connectionString))
            {
                var cmd = sproc.Build(con);

                await con.OpenAsync();
                var obj = loader.Dynamic(cmd);

                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);
            }
        }
Exemplo n.º 12
0
        public async Task DataReaderDictionaries()
        {
            using (var con = new SqlConnection(connectionString))
            {
                var sproc = new dboSelectMultipleStatement();

                var cmd = sproc.Build(con);

                var loader = new DynamicLoader();
                await con.OpenAsync();

                var reader = await cmd.ExecuteReaderAsync();
                var objs = loader.Dictionaries(reader);

                Assert.IsNotNull(objs);

                var i = 0;
                foreach (var obj in objs)
                {
                    Assert.AreEqual(i, obj["Identifier"]);
                    i++;
                }
            }
        }