public void VerifySingleFieldFieldsWithSingleOption(ElementTypeIdentifierPath messageType, string fieldName , OptionIdentifierPath optionName) { const LabelKind label = LabelKind.Required; IVariant fieldType = Variant.Create(ProtoType.Double); IVariant optionConst = Constant.Create(true); IEnumerable <FieldOption> GetFieldOptions() => GetRange( new FieldOption { Name = optionName, Value = optionConst } ); IEnumerable <NormalFieldStatement> GetNormalFields() { var fieldNumber = FieldNumber; yield return(new NormalFieldStatement { Name = fieldName, Label = label, FieldType = fieldType, Number = fieldNumber, Options = GetFieldOptions().ToList() }); } ExpectedTopLevel = new ExtendStatement { MessageType = messageType, Items = GetNormalFields().ToList <IExtendBodyItem>() }; }
public void VerifySingleFieldFieldsWithSingleOptionWithWhiteSpace(ElementTypeIdentifierPath messageType , string fieldName, OptionIdentifierPath optionName, WhiteSpaceAndCommentOption whiteSpaceOption) { RenderingOptions = new StringRenderingOptions { WhiteSpaceAndCommentRendering = whiteSpaceOption }; VerifySingleFieldFieldsWithSingleOption(messageType, fieldName, optionName); }
public void VerifyEmptyBodyWithWhiteSpace(ElementTypeIdentifierPath messageType , WhiteSpaceAndCommentOption option) { RenderingOptions = new StringRenderingOptions { WhiteSpaceAndCommentRendering = option }; VerifyEmptyBody(messageType); }
public void VerifyFromZeroGroupsWithWhiteSpace(ElementTypeIdentifierPath messageType, LabelKind label , string[] groupNames, long fieldNumber, WhiteSpaceAndCommentOption whiteSpaceOption) { RenderingOptions = new StringRenderingOptions { WhiteSpaceAndCommentRendering = whiteSpaceOption }; VerifyFromZeroGroups(messageType, label, groupNames, fieldNumber); }
public void VerifyFromZeroFieldsWithOrWithoutOptionsWithWhiteSpace(ElementTypeIdentifierPath messageType , string[] fieldNames, OptionIdentifierPath[] optionNames, WhiteSpaceAndCommentOption whiteSpaceOption) { VerifyFromZeroFieldsWithOrWithoutOptions(messageType, fieldNames, optionNames); RenderingOptions = new StringRenderingOptions { WhiteSpaceAndCommentRendering = whiteSpaceOption }; }
public void VerifyFromZeroGroups(ElementTypeIdentifierPath messageType, LabelKind label , string[] groupNames, long fieldNumber) { IEnumerable <IExtendBodyItem> GetStatementItems() => groupNames.Select <string, IExtendBodyItem>( x => new GroupFieldStatement { Name = x, Label = label, Number = fieldNumber } ); ExpectedTopLevel = new ExtendStatement { MessageType = messageType, Items = GetStatementItems().ToList() }; }
// ReSharper disable once InconsistentNaming /// <summary> /// /// </summary> /// <param name="length"></param> /// <param name="parts"></param> /// <param name="globalScope"></param> /// <returns></returns> internal static ElementTypeIdentifierPath GetElementTypeIdentifierPath(int length, int parts, bool globalScope) { var path = new ElementTypeIdentifierPath { IsGlobalScope = globalScope }; while (parts-- > 0) { path.Add(GetIdent(length)); } return(path); }
public void VerifyFromZeroFieldsWithOrWithoutOptions(ElementTypeIdentifierPath messageType , string[] fieldNames, OptionIdentifierPath[] optionNames) { const LabelKind label = LabelKind.Required; IVariant fieldType = Variant.Create(ProtoType.Double); IVariant optionConst = Constant.Create(true); IEnumerable <FieldOption> GetFieldOptions() => optionNames.Select( x => new FieldOption { Name = x, Value = optionConst } ); IEnumerable <NormalFieldStatement> GetNormalFields() { foreach (var fieldName in fieldNames) { var fieldNumber = FieldNumber; yield return(new NormalFieldStatement { Name = fieldName, Label = label, FieldType = fieldType, Number = fieldNumber, Options = GetFieldOptions().ToList() }); } } ExpectedTopLevel = new ExtendStatement { MessageType = messageType, Items = GetNormalFields().ToList <IExtendBodyItem>() }; }
/// <summary> /// Visits the <paramref name="path"/>. /// </summary> /// <param name="path"></param> protected virtual void VisitElementTypeIdentifierPath(ElementTypeIdentifierPath path) { }
public void VerifyEmptyBody(ElementTypeIdentifierPath messageType) { ExpectedTopLevel = new ExtendStatement { MessageType = messageType }; }
/// <inheritdoc /> public bool Equals(ElementTypeIdentifierPath other) => Equals(this, other);
/// <summary> /// Returns whether <paramref name="a"/> Equals <paramref name="b"/>. /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> protected internal static bool Equals(ElementTypeIdentifierPath a, ElementTypeIdentifierPath b) => IdentifierPath.Equals(a, b) && a.IsGlobalScope == b.IsGlobalScope;
public void VerifyExtendStatementWithEmptyStatement(ElementTypeIdentifierPath messageType) { ExpectedTopLevel = new ExtendStatement { MessageType = messageType, Items = { NewEmptyStatement } }; }