public void CopyInt16ThrowsExceptionWhenIndexOutOfRange() { const int dataTypeLengthInBytes = 2; const short anyValueWillDo = 1; var sut = new StandardDataTypeImpl(AnyValidIndexWillDo, AnyBulkCopyDataTypeWillDo, dataTypeLengthInBytes, BindingFlags.None); TestHelper.AssertThrows<ArgumentOutOfRangeException>(() => sut.CopyInt16(-1, anyValueWillDo)); TestHelper.AssertThrows<ArgumentOutOfRangeException>(() => sut.CopyInt16(dataTypeLengthInBytes, anyValueWillDo)); }
public void CopyInt16BehavesAsExpected() { const int dataTypeLengthInBytes = 2; const short minValue = short.MinValue; const short maxValue = short.MaxValue; var sut = new StandardDataTypeImpl(AnyValidIndexWillDo, AnyBulkCopyDataTypeWillDo, dataTypeLengthInBytes, BindingFlags.None); Assert.AreEqual(0, sut.IndicatorLength); sut.CopyInt16(0, minValue); Assert.AreEqual(minValue, BitConverter.ToInt16(sut.Data, sut.IndicatorLength)); sut.CopyInt16(0, maxValue); Assert.AreEqual(maxValue, BitConverter.ToInt16(sut.Data, sut.IndicatorLength)); sut = new StandardDataTypeImpl(AnyValidIndexWillDo, AnyBulkCopyDataTypeWillDo, dataTypeLengthInBytes, BindingFlags.Nullable); Assert.AreEqual(IndicatorLength, sut.IndicatorLength); sut.CopyInt16(0, minValue); Assert.AreEqual(minValue, BitConverter.ToInt16(sut.Data, sut.IndicatorLength)); sut.CopyInt16(0, maxValue); Assert.AreEqual(maxValue, BitConverter.ToInt16(sut.Data, sut.IndicatorLength)); }