public void CopyByteThrowsExceptionWhenIndexOutOfRange() { const int dataTypeLengthInBytes = 1; const byte anyValueWillDo = 1; var sut = new StandardDataTypeImpl(AnyValidIndexWillDo, AnyBulkCopyDataTypeWillDo, dataTypeLengthInBytes, BindingFlags.None); TestHelper.AssertThrows<ArgumentOutOfRangeException>(() => sut.CopyByte(-1, anyValueWillDo)); TestHelper.AssertThrows<ArgumentOutOfRangeException>(() => sut.CopyByte(dataTypeLengthInBytes, anyValueWillDo)); }
public void CopyByteBehavesAsExpected() { const int dataTypeLengthInBytes = 1; const byte minValue = byte.MinValue; const byte maxValue = byte.MaxValue; var sut = new StandardDataTypeImpl(AnyValidIndexWillDo, AnyBulkCopyDataTypeWillDo, dataTypeLengthInBytes, BindingFlags.None); Assert.AreEqual(0, sut.IndicatorLength); sut.CopyByte(0, minValue); Assert.AreEqual(minValue, sut.Data[sut.IndicatorLength]); sut.CopyByte(0, maxValue); Assert.AreEqual(maxValue, sut.Data[sut.IndicatorLength]); sut = new StandardDataTypeImpl(AnyValidIndexWillDo, AnyBulkCopyDataTypeWillDo, dataTypeLengthInBytes, BindingFlags.Nullable); Assert.AreEqual(IndicatorLength, sut.IndicatorLength); sut.CopyByte(0, minValue); Assert.AreEqual(minValue, sut.Data[sut.IndicatorLength]); sut.CopyByte(0, maxValue); Assert.AreEqual(maxValue, sut.Data[sut.IndicatorLength]); }