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)); }