public void SetsInvalidValueReasonCorrectly(string input, InvalidEnumValueReason expected) { // Arrange var @enum = new EnumBuilder().Build(); var memberNode = ParserInput .FromString(input) .ParseInput(parser => parser.enumMember()); // Act var member = this.Binder.Bind <EnumMember>(memberNode, @enum); // Assert Assert.Equal(expected, member.InvalidValueReason); }
/// <summary> /// Initializes a new instance of the <see cref="EnumMember" /> class. /// </summary> /// <param name="node">The node associated with the symbol.</param> /// <param name="parent">The enum that contains this member.</param> /// <param name="name">The name of the enum member.</param> /// <param name="value">The value of the enum member.</param> /// <param name="rawValue">The raw text representation of the value.</param> /// <param name="invalidValueReason">The reason the enum value failed to parse.</param> /// <param name="isValueImplicit"> /// Indicates whether the value is implicit (i.e. has been automatically /// generated by the compiler rather than being specified in the source). /// </param> public EnumMember( EnumMemberContext node, IEnum parent, string name, int?value, string rawValue, InvalidEnumValueReason invalidValueReason, bool isValueImplicit) : base(node, parent) { this.Name = name; this.Value = value; this.RawValue = rawValue; this.InvalidValueReason = invalidValueReason; this.IsValueImplicit = isValueImplicit; }
/// <summary> /// Sets the reason the enum value is invalid. /// </summary> /// <param name="invalidValueReason">The reason the value is invalid.</param> /// <returns>The builder.</returns> public EnumMemberBuilder SetInvalidValueReason(InvalidEnumValueReason invalidValueReason) { this.InvalidValueReason = invalidValueReason; return(this); }