public void ShouldGetItemsByNameAndOrdinalFromCollection()
        {
            var customers = new List<Customer> {
                new Customer {
                    Name = "Peter",
                    Age = 29
                }
            };

            var col = new DataReaderCollection<Customer>(customers);

            Assert.That(col.HasRows, Is.True);

            col.NextResult();
            Assert.That(col.GetString(col.GetOrdinal("Name")), Is.EqualTo("Peter"));
            Assert.That(col.GetString(0), Is.EqualTo("Peter"));

            Assert.That(col.GetInt32(col.GetOrdinal("Age")), Is.EqualTo(29));
            Assert.That(col.GetInt32(2), Is.EqualTo(29));
        }
        public void ShouldInstantiateCollection()
        {
            var customers = Builder<Customer>.CreateListOfSize(10).Build();

            var col = new DataReaderCollection<Customer>(customers);
            Assert.That(col.HasRows, Is.True);
            int i = 0;
            while (col.NextResult())
            {
                i++;
                Assert.That(col.GetString(col.GetOrdinal("Name")), Is.EqualTo("Name" + i.ToString()));
                Assert.That(col.GetString(0), Is.EqualTo("Name" + i.ToString()));

                Assert.That(col.GetInt32(col.GetOrdinal("Age")), Is.EqualTo(i));
                Assert.That(col.GetInt32(2), Is.EqualTo(i));
            }
            Assert.That(i, Is.EqualTo(10));
        }
 public void ShouldGetValuesOfEachType()
 {
     var objs = Builder<ComplexObject>.CreateListOfSize(1).Build();
     var col = new DataReaderCollection<ComplexObject>(objs);
     col.Read();
     Assert.That(col.GetInt32(col.GetOrdinal("AInt")), Is.EqualTo(1));
     Assert.That(col.GetInt16(col.GetOrdinal("BInt16")), Is.EqualTo(1));
     Assert.That(col.GetInt64(col.GetOrdinal("CInt64")), Is.EqualTo(1));
     Assert.That(col.GetDecimal(col.GetOrdinal("DDecimal")), Is.EqualTo(1.0m));
     Assert.That(col.GetFloat(col.GetOrdinal("EFloat")), Is.EqualTo(1.0f));
     Assert.That(col.GetDouble(col.GetOrdinal("FDouble")), Is.EqualTo(1.0d));
     Assert.That(col.GetBoolean(col.GetOrdinal("GBoolean")), Is.EqualTo(false));
     Assert.That(col.GetByte(col.GetOrdinal("HByte")), Is.EqualTo(1));
     Assert.That(col.GetChar(col.GetOrdinal("IChar")), Is.EqualTo('A'));
     Assert.That(col.GetString(col.GetOrdinal("JString")), Is.EqualTo("JString1"));
     Assert.That(col.GetDateTime(col.GetOrdinal("KDateTime")), Is.GreaterThan(DateTime.Now.AddDays(-1)));
     Assert.That(col.GetGuid(col.GetOrdinal("LGuid")), Is.EqualTo(Guid.Parse("00000000-0000-0000-0000-000000000001")));
 }