internal DhcpNetWareSubOptionsOption(DhcpBinaryValue binaryValue) { var firstByteBinaryValue = binaryValue.CreateSubsetValue(0, 1); State = ParseState(firstByteBinaryValue); var remainingValueLength = binaryValue.Length - 1; if (remainingValueLength > 0) { if (!StateAllowsSubOptions()) { throw new FormatException( $"The NetWare sub options first byte is {State} which does not allow further sub options, but other sub options have been found."); } var subOptionsBinaryValue = binaryValue.CreateSubsetValue(1, binaryValue.Length - 1); SubOptions = ParseSubOptions(subOptionsBinaryValue); } else { SubOptions = new INetWareSubOption[0]; } }
public void ThrowArgumentOutOfRange_GivenOffsetAndLengthExceedingLimit() { var binaryValue = new DhcpBinaryValue(Bytes, 0, 3); Assert.Throws <ArgumentOutOfRangeException>( () => binaryValue.CreateSubsetValue(2, 2)); }
public void ThrowArgumentOutOfRange_GivenLengthExceedingDataLength(int length) { var binaryValue = new DhcpBinaryValue(Bytes, 0, Bytes.Length); Assert.Throws <ArgumentOutOfRangeException>( () => binaryValue.CreateSubsetValue(0, length)); }
public void ThrowArgumentOutOfRange_GivenOffsetExceedingLength(int offset) { var binaryValue = new DhcpBinaryValue(Bytes, 0, Bytes.Length); Assert.Throws <ArgumentOutOfRangeException>( () => binaryValue.CreateSubsetValue(offset, 2)); }
public void ReturnSubSetValue() { var binaryValue = new DhcpBinaryValue(Bytes, 0, Bytes.Length); var subsetValue = binaryValue.CreateSubsetValue(2, 2); var expectedValue = new byte[] { 0x03, 0x04 }; Assert.Equal(expectedValue, subsetValue.AsBytes()); }