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 IsClosed_Always_ReturnsFalse() { // arrange var sut = new CacheableDataReader(mockDataReader.Object); var isClosed = sut.IsClosed; // act sut.Close(); isClosed |= sut.IsClosed; // assert Assert.That(isClosed, Is.False); }
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 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 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 GetData_WhenCalled_ThrowsException() { // arrange var sut = new CacheableDataReader(actualDataReader); // assert Assert.Throws<NotSupportedException>(() => sut.GetData(0)); // <- happy with this for now, super edge case I won't handle }
public void NextResult_NotImplemented_ThrowsException() { // arrange var dataReader = new DataTableReader(new[] { BuildDataTable(), BuildDataTable() }); var sut = new CacheableDataReader(dataReader); // assert Assert.Throws<NotImplementedException>(() => sut.NextResult()); }
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")); }
public void GetSchemaTable_WhenCalled_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); // act var actual = sut.GetSchemaTable(); // assert Assert.That(actual, Is.Not.Null); // <- only sane thing to check? }
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 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 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 GetEnumerator_WhenCalled_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); // act var actual = sut.GetEnumerator(); // assert Assert.That(actual, Is.Not.Null); // <- only sane thing to check directly? Assert.That(sut.Cast<IDataRecord>().Count(), Is.EqualTo(1)); // <- implies GetEnumerator, probably brittle }
public void GetOrdinal_GivenName_ReturnsCorrectly() { // arrange var sut = new CacheableDataReader(actualDataReader); // act var index = sut.GetOrdinal("GuidColumn"); // assert Assert.That(index, Is.EqualTo(1)); }