public void Read_WhenCalledAfterClose_ShouldAlwaysWork() { // arrange var sut = new CacheableDataReader(actualDataReader); var reads = sut.Read(); // act sut.Close(); reads &= sut.Read(); // assert Assert.That(reads, Is.True); }
public void GetChar_GivenOrdinal_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); sut.Read(); // act var val = sut.GetChar(sut.GetOrdinal("CharColumn")); // assert Assert.That(val, Is.EqualTo('!')); }
public void GetChars_GivenOrdinal_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); var buffer = new char[2]; sut.Read(); // act sut.GetChars(sut.GetOrdinal("CharsColumn"), 0, buffer, 0, 2); // assert Assert.That(buffer, Is.EquivalentTo(new char[] { '!', '#' })); }
public void GetBytes_GivenOrdinal_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); var buffer = new byte[2]; sut.Read(); // act sut.GetBytes(sut.GetOrdinal("BytesColumn"), 0, buffer, 0, 2); // assert Assert.That(buffer, Is.EquivalentTo(new byte[] { 13, 37 })); }
public void GetDataTypeName_GivenOrdinal_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); sut.Read(); // act var val = sut.GetDataTypeName(sut.GetOrdinal("BytesColumn")); // assert Assert.That(val, Is.EqualTo("Byte[]")); }
public void FieldCount_Getter_ReturnsDepth() { // arrange var expected = actualDataReader.FieldCount; var sut = new CacheableDataReader(actualDataReader); sut.Read(); // act var actual = sut.FieldCount; // assert Assert.That(actual, Is.EqualTo(expected)); }
public void RecordsAffected_Getter_ReturnsDepth() { // arrange var expected = actualDataReader.RecordsAffected; var sut = new CacheableDataReader(actualDataReader); sut.Read(); // act var actual = sut.RecordsAffected; // assert Assert.That(actual, Is.EqualTo(expected)); }
public void IsDBNull_GivenNullOrdinal_ReturnsTrue() { // arrange var sut = new CacheableDataReader(actualDataReader); sut.Read(); // act var isNull = sut.IsDBNull(sut.GetOrdinal("NullColumn")); // assert Assert.That(isNull, Is.True); }
public void Indexer_GivenOrdinal_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); sut.Read(); // act var val = sut[sut.GetOrdinal("GuidColumn")]; // assert Assert.That(val, Is.EqualTo(GuidData)); }
public void GetValues_GivenOrdinal_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); sut.Read(); var expectedData = new object[] { "AStringValue", // StringColumn GuidData, // GuidColumn 13, // Int16Column 14, // Int32Column 15, // Int64Column DBNull.Value, // NullColumn true, // BooleanColumn 5, // ByteColumn new byte[] { 13, 37 }, // BytesColumn '!', // CharColumn new char[] { '!', '#' }, // CharsColumn DateTimeData, // DateTimeColumn 210, // DecimalColumn 1790, // DoubleColumn 1790, // FloatColumn ObjectData }; var actualData = new object[100]; // act var numberOfResults = sut.GetValues(actualData); // assert Assert.That(numberOfResults, Is.EqualTo(expectedData.Length)); Assert.That(actualData.Take(numberOfResults).ToArray(), Is.EquivalentTo(expectedData)); }
public void GetValue_GivenOrdinal_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); sut.Read(); // act var val = sut.GetValue(sut.GetOrdinal("ObjectColumn")); // assert Assert.That(val, Is.EqualTo(ObjectData)); }
public void GetString_GivenOrdinal_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); sut.Read(); // act var val = sut.GetString(sut.GetOrdinal("StringColumn")); // assert Assert.That(val, Is.EqualTo("AStringValue")); }