[SetUp] public void SetUp() { _mockery = new MockRepository(); _testee = new ExtendedDataReaderWrapper(); _wrapped = _mockery.StrictMock <IDataReader>(); _cache = _mockery.StrictMock <IDataRecordOrdinalCache>(); }
[Test] public void GetInnerMostReaderMultiLayer() { var wrapper1 = new ExtendedDataReaderWrapper { WrappedReader = _wrapped }; var wrapper2 = new NullMappingDataReader(wrapper1); _testee.WrappedReader = wrapper2; _mockery.ReplayAll(); Assert.That(_testee.GetInnerMostReader(), Is.EqualTo(_wrapped)); }
public void WrapDataReaderReturnsOriginalWhenAlreadyExtended(int rowsExpected) { var extendedReader = new ExtendedDataReaderWrapper(); _ordinalCache.Init(_dataReader); _mockery.ReplayAll(); extendedReader.WrappedReader = _dataReader; testee.OrdinalCache = _ordinalCache; testee.RowsExpected = rowsExpected; var reader = testee.ExtendDataReader(extendedReader); Assert.That(reader, Is.SameAs(extendedReader)); Assert.That(extendedReader.OrdinalCache, Is.SameAs(_ordinalCache)); Assert.That(testee.OrdinalCache, Is.SameAs(_ordinalCache)); Assert.That(extendedReader.RowsExpected, Is.EqualTo(rowsExpected > 0 ? rowsExpected : 0)); Assert.That(testee.RowsExpected, Is.EqualTo(rowsExpected)); _mockery.VerifyAll(); }
internal IDataReader ExtendDataReader(IDataReader reader) { if (_ordinalCache != null || _rowsExpected > 0) { var wrapper = reader as ExtendedDataReaderWrapper; if (_ordinalCache != null) { if (wrapper == null) { wrapper = new ExtendedDataReaderWrapper { WrappedReader = reader }; } wrapper.OrdinalCache = _ordinalCache; } if (_rowsExpected > 0 && wrapper != null) { wrapper.RowsExpected = _rowsExpected; } return(wrapper ?? reader); } return(reader); }