public void CopyInt32ThrowsExceptionWhenIndexOutOfRange() { const int dataTypeLengthInBytes = 4; const int anyValueWillDo = 1; var sut = new StandardDataTypeImpl(AnyValidIndexWillDo, AnyBulkCopyDataTypeWillDo, dataTypeLengthInBytes, BindingFlags.None); TestHelper.AssertThrows<ArgumentOutOfRangeException>(() => sut.CopyInt32(-1, anyValueWillDo)); TestHelper.AssertThrows<ArgumentOutOfRangeException>(() => sut.CopyInt32(dataTypeLengthInBytes, anyValueWillDo)); }
public void CopyInt32BehavesAsExpected() { const int dataTypeLengthInBytes = 4; const int minValue = int.MinValue; const int maxValue = int.MaxValue; var sut = new StandardDataTypeImpl(AnyValidIndexWillDo, AnyBulkCopyDataTypeWillDo, dataTypeLengthInBytes, BindingFlags.None); Assert.AreEqual(0, sut.IndicatorLength); sut.CopyInt32(0, minValue); Assert.AreEqual(minValue, BitConverter.ToInt32(sut.Data, sut.IndicatorLength)); sut.CopyInt32(0, maxValue); Assert.AreEqual(maxValue, BitConverter.ToInt32(sut.Data, sut.IndicatorLength)); sut = new StandardDataTypeImpl(AnyValidIndexWillDo, AnyBulkCopyDataTypeWillDo, dataTypeLengthInBytes, BindingFlags.Nullable); Assert.AreEqual(IndicatorLength, sut.IndicatorLength); sut.CopyInt32(0, minValue); Assert.AreEqual(minValue, BitConverter.ToInt32(sut.Data, sut.IndicatorLength)); sut.CopyInt32(0, maxValue); Assert.AreEqual(maxValue, BitConverter.ToInt32(sut.Data, sut.IndicatorLength)); }