• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LBreedlove / Queuebal.Expressions / 15908999684

26 Jun 2025 05:54PM UTC coverage: 83.965% (-5.9%) from 89.828%
15908999684

Pull #12

github

web-flow
Merge cadde457a into 3fa62aa5d
Pull Request #12: Add (Length)Greater/LessThan conditions

327 of 376 branches covered (86.97%)

Branch coverage included in aggregate %.

8 of 160 new or added lines in 8 files covered. (5.0%)

1977 of 2368 relevant lines covered (83.49%)

486.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

3.23
/Queuebal.Expressions.Conditions/LengthIsLessThanCondition.cs
1
using Queuebal.Json;
2

3
namespace Queuebal.Expressions.Conditions;
4

5
/// <summary>
6
/// A condition that checks if the input value's length is less than the comparer value,
7
/// or the length of the comparer value.
8
/// </summary>
9
public class LengthIsLessThanCondition : BinaryCondition
10
{
NEW
11
    private static HashSet<JSONFieldType> _validInputTypes => new()
×
NEW
12
    {
×
NEW
13
        JSONFieldType.String,
×
NEW
14
        JSONFieldType.List,
×
NEW
15
        JSONFieldType.Dictionary,
×
NEW
16
    };
×
17

18
    /// <summary>
19
    /// Gets the name of the condition type.
20
    /// </summary>
21
    public static string ConditionType { get; } = "LengthIsLessThan";
9✔
22

23
    /// <summary>
24
    /// Evaluates the condition by checking if the input value's length is less than the specified value.
25
    /// </summary>
26
    /// <param name="context">The context the condition is running in.</param>
27
    /// <param name="inputValue">The value to compare against.</param>
28
    /// <returns>true if the input value's length is less than the specified value, otherwise false.</returns>
29
    protected override bool EvaluateCondition(ExpressionContext context, JSONValue inputValue, JSONValue comparerValue)
NEW
30
    {
×
NEW
31
        if (inputValue.IsNull)
×
NEW
32
        {
×
NEW
33
            return false;
×
34
        }
35

NEW
36
        if (!_validInputTypes.Contains(inputValue.FieldType))
×
NEW
37
        {
×
NEW
38
            throw new InvalidOperationException("IsLengthGreaterThan inputValue must be a string, list, or dictionary");
×
39
        }
40

NEW
41
        int length = GetLength(inputValue);
×
NEW
42
        if (comparerValue.IsInteger)
×
NEW
43
        {
×
NEW
44
            return length < comparerValue.IntValue;
×
45
        }
46

NEW
47
        return length < GetLength(comparerValue);
×
NEW
48
    }
×
49

50
    /// <summary>
51
    /// Gets the length of the given JSONValue, if the value is a string, list, or dictionary.
52
    /// </summary>
53
    /// <param name="value">The value to get the length of.</param>
54
    /// <returns>The length of the value.</returns>
55
    /// <exception cref="InvalidOperationException">Thrown when the value is not a string, list, or dictionary.</exception>
NEW
56
    private static int GetLength(JSONValue value) => value.FieldType switch
×
NEW
57
    {
×
NEW
58
        JSONFieldType.String => value.StringValue.Length,
×
NEW
59
        JSONFieldType.List => value.ListValue.Count,
×
NEW
60
        JSONFieldType.Dictionary => value.DictValue.Count,
×
NEW
61
        _ => throw new InvalidOperationException("IsLengthGreater than can only accept a string, list, or dictionary")
×
NEW
62
    };
×
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc