public void ShouldParseSuccess(string limitStr, int offset, int limit) { var limitInfo = LimitInfo.Parse(limitStr); limitInfo.Offset.Should().Be(offset); limitInfo.Limit.Should().Be(limit); }
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); }
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"); }
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); }
public void ShouldParseFailure(string limitStr) { var action = new Action(() => LimitInfo.Parse(limitStr)); action.Should().Throw <FilterInfoParseException>(); }
private string LimitInfoToString(LimitInfo limitInfo) { return(limitInfo != null ? $"{nameof(Limit).ToLower()}({limitInfo})" : null); }
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)); }