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

LBreedlove / Queuebal.Expressions / 18445802153

12 Oct 2025 03:17PM UTC coverage: 96.312% (-0.3%) from 96.599%
18445802153

push

github

web-flow
refactor mutations so params have access to source data (#24)

442 of 447 branches covered (98.88%)

Branch coverage included in aggregate %.

87 of 95 new or added lines in 17 files covered. (91.58%)

2 existing lines in 2 files now uncovered.

2692 of 2807 relevant lines covered (95.9%)

422.91 hits per line

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

88.24
/Queuebal.Expressions.Mutations/StringSplitMutation.cs
1
using Queuebal.Json;
2

3
namespace Queuebal.Expressions.Mutations;
4

5

6
public class StringSplitMutation : Mutation
7
{
8
    public static string MutationType => "StringSplit";
5✔
9

10
    /// <summary>
11
    /// The separators used to split the string.
12
    /// </summary>
13
    public required List<IExpression> Separators { get; set; }
19✔
14

15
    /// <summary>
16
    /// If true, empty entries will be removed from the result.
17
    /// </summary>
18
    public bool RemoveEmptyEntries { get; set; } = false;
23✔
19

20
    /// <summary>
21
    /// If true, leading and trailing whitespace will be removed from each entry in the result.
22
    /// This is applied after splitting the string.
23
    /// If RemoveEmptyEntries is true, this will also remove entries that are only whitespace.
24
    /// </summary>
25
    public bool TrimEntries { get; set; } = false;
22✔
26

27
    protected override JSONValue EvaluateMutation(ExpressionContext context, JSONValue originalValue, JSONValue sourceData)
28
    {
6✔
29
        if (!originalValue.IsString)
6✔
30
        {
1✔
31
            throw new InvalidOperationException("StringSplitMutation can only be applied to a string input value.");
1✔
32
        }
33

34
        var splitOptions = StringSplitOptions.None;
5✔
35
        if (RemoveEmptyEntries)
5✔
36
        {
2✔
37
            splitOptions |= StringSplitOptions.RemoveEmptyEntries;
2✔
38
        }
2✔
39

40
        if (TrimEntries)
5✔
41
        {
1✔
42
            splitOptions |= StringSplitOptions.TrimEntries;
1✔
43
        }
1✔
44

45
        var separators = Separators.Select(s => s.Evaluate(context, sourceData)).ToList();
10✔
46
        if (separators.Count == 0)
5✔
NEW
47
        {
×
NEW
48
            throw new InvalidOperationException("StringSplitMutation requires at least one separator.");
×
49
        }
50

51
        if (separators.Select(s => s.IsString).Any(v => !v))
15✔
NEW
52
        {
×
NEW
53
            throw new InvalidOperationException("All Separators expressions must evaluate to string values.");
×
54
        }
55

56
        return originalValue.StringValue
5✔
57
                .Split(separators.Select(s => s.StringValue[0]).ToArray(), splitOptions)
5✔
58
                .Select(s => new JSONValue(s))
11✔
59
                .ToList();
5✔
60
    }
5✔
61
}
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