コード例 #1
0
        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>()
            };
        }
コード例 #2
0
 public void VerifyMessageBodyWithEmptyGroupFieldWithWhiteSpace(LabelKind label, string groupName
                                                                , long fieldNumber, WhiteSpaceAndCommentOption whiteSpaceOption)
 {
     RenderingOptions = new StringRenderingOptions {
         WhiteSpaceAndCommentRendering = whiteSpaceOption
     };
     VerifyMessageBodyWithEmptyGroupField(label, groupName, fieldNumber);
 }
コード例 #3
0
 public void VerifyMessageBodyWithEmptyGroupField(LabelKind label, string groupName, long fieldNumber)
 {
     ExpectedBody.Add(
         new GroupFieldStatement {
         Label = label, Name = groupName, Number = fieldNumber
     }
         );
 }
コード例 #4
0
 public virtual void VerifyMessageBodyWithNormalFieldWithWhiteSpace(LabelKind label, IVariant fieldType
                                                                    , string fieldName, long fieldNumber, WhiteSpaceAndCommentOption whiteSpaceOption)
 {
     RenderingOptions = new StringRenderingOptions {
         WhiteSpaceAndCommentRendering = whiteSpaceOption
     };
     VerifyMessageBodyWithNormalField(label, fieldType, fieldName, fieldNumber);
 }
コード例 #5
0
 public virtual void VerifyMessageBodyWithNormalField(LabelKind label, IVariant fieldType, string fieldName
                                                      , long fieldNumber)
 {
     ExpectedBody.Add(new NormalFieldStatement
     {
         Label     = label,
         FieldType = fieldType,
         Name      = fieldName,
         Number    = fieldNumber
     });
 }
コード例 #6
0
        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()
            };
        }
コード例 #7
0
        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>()
            };
        }
コード例 #8
0
 /// <summary>
 /// Visits the <paramref name="value"/>.
 /// </summary>
 /// <param name="value"></param>
 protected virtual void VisitLabel(LabelKind value)
 {
 }
コード例 #9
0
 /// <summary>
 /// Renders the <paramref name="value"/> given the <paramref name="options"/>.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public static string ToDescriptorString(this LabelKind value, IStringRenderingOptions options)
 => $"{ValueMapping[value]}";
コード例 #10
0
 /// <summary>
 /// Renders <paramref name="value"/> as a string assuming default
 /// <see cref="IStringRenderingOptions"/>.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static string ToDescriptorString(this LabelKind value)
 => value.ToDescriptorString(new StringRenderingOptions {
 });
コード例 #11
0
 public void VerifyFromZeroGroupsWithWhiteSpace(ElementTypeIdentifierPath messageType, LabelKind label
                                                , string[] groupNames, long fieldNumber, WhiteSpaceAndCommentOption whiteSpaceOption)
 {
     RenderingOptions = new StringRenderingOptions {
         WhiteSpaceAndCommentRendering = whiteSpaceOption
     };
     VerifyFromZeroGroups(messageType, label, groupNames, fieldNumber);
 }
コード例 #12
0
        public Task <IShipmentServerResponse <Shipment> > SubmitShipmentAsync(Shipment shipment, LabelKind label = LabelKind.None, bool calculatePrice = false)
        {
            var options = new { Labels = label == LabelKind.None ? null : Enum.GetName(typeof(LabelKind), label), PriceCalculation = calculatePrice ? 1 : 0 }.ToJson();

            return(Request <Shipment>("SubmitShipment", shipment.ToJson(), options));
        }
コード例 #13
0
        public Task <IShipmentServerResponse <LabelCollection> > ReprintLabelsAsync(int shpCSID, LabelKind kind)
        {
            var data = new { ShpCSID = shpCSID }.ToJson();
            var options = new { Labels = Enum.GetName(typeof(LabelKind), kind) }.ToJson();

            return(Request <LabelCollection>("ReprintLabels", data, options));
        }