Exemple #1
0
        public void ShouldParseSuccess(string limitStr, int offset, int limit)
        {
            var limitInfo = LimitInfo.Parse(limitStr);

            limitInfo.Offset.Should().Be(offset);
            limitInfo.Limit.Should().Be(limit);
        }
Exemple #2
0
        public void ShouldParsePageInfoSuccess(int pageIndex, int pageSize, int offset, int limit)
        {
            var limitInfo = LimitInfo.FromPageInfo(pageIndex, pageSize);

            limitInfo.Offset.Should().Be(offset);
            limitInfo.Limit.Should().Be(limit);
        }
Exemple #3
0
        public void ShouldConvertToStringSuccess()
        {
            TypeConverter typeConverter = TypeDescriptor.GetConverter(typeof(LimitInfo));
            var           canToString   = typeConverter.CanConvertTo(typeof(string));

            canToString.Should().Be(true);
            LimitInfo limitInfo = new LimitInfo(100, 20);

            typeConverter.ConvertTo(limitInfo, typeof(string)).Should().Be("100,20");
        }
Exemple #4
0
        public LimitInfo ParseLimitInfo(string text)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return(null);
            }
            var       context   = new ParseContext(text, this.CurrentCulture);
            LimitInfo limitInfo = context.ParseLimitInfo();

            context.SkipWhiteSpace();
            if (context.NotEnd())
            {
                throw ParseErrors.InvalidText(context);
            }
            return(limitInfo);
        }
Exemple #5
0
        public void ShouldParseFailure(string limitStr)
        {
            var action = new Action(() => LimitInfo.Parse(limitStr));

            action.Should().Throw <FilterInfoParseException>();
        }
Exemple #6
0
 private string LimitInfoToString(LimitInfo limitInfo)
 {
     return(limitInfo != null ? $"{nameof(Limit).ToLower()}({limitInfo})" : null);
 }
Exemple #7
0
 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
 {
     return((value is string limttInfo) ? LimitInfo.Parse(limttInfo) : base.ConvertFrom(context, culture, value));
 }