public DHCPv6NumericValueScopeProperty( UInt16 optionIdentifier, Int64 value, NumericScopePropertiesValueTypes numericType, DHCPv6ScopePropertyType valueType) : base(optionIdentifier, valueType) { Value = value; NumericType = numericType; }
public void Constructor(UInt16 optionIdentifier, Int64 value, NumericScopePropertiesValueTypes numericType, DHCPv6ScopePropertyType valueType) { var property = new DHCPv6NumericValueScopeProperty(optionIdentifier, value, numericType, valueType); Assert.Equal(valueType, property.ValueType); Assert.Equal(optionIdentifier, property.OptionIdentifier); Assert.Equal(numericType, property.NumericType); Assert.Equal(value, property.Value); var otherProperty = DHCPv6NumericValueScopeProperty.FromRawValue(optionIdentifier, value.ToString(), numericType); Assert.Equal(property, otherProperty); }
public static DHCPv6NumericValueScopeProperty FromRawValue(UInt16 optionIdentifier, String rawValue, NumericScopePropertiesValueTypes numericValueType) { if (INumericValueScopeProperty.ValueIsInRange(rawValue, numericValueType) == false) { throw new ArgumentException(nameof(rawValue)); } Int64 value = Convert.ToInt64(rawValue); var propertyType = numericValueType switch { NumericScopePropertiesValueTypes.Byte => DHCPv6ScopePropertyType.Byte, NumericScopePropertiesValueTypes.UInt16 => DHCPv6ScopePropertyType.UInt16, NumericScopePropertiesValueTypes.UInt32 => DHCPv6ScopePropertyType.UInt32, _ => throw new ArgumentException(nameof(numericValueType)), }; return(new DHCPv6NumericValueScopeProperty(optionIdentifier, value, numericValueType, propertyType)); }