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

lucaslorentz / auto-compute / 11763467169

10 Nov 2024 08:07AM UTC coverage: 77.292% (-12.0%) from 89.255%
11763467169

push

github

lucaslorentz
Add initial support for computed navigations and observers

168 of 433 new or added lines in 25 files covered. (38.8%)

7 existing lines in 5 files now uncovered.

1467 of 1898 relevant lines covered (77.29%)

109.86 hits per line

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

77.42
/src/LLL.AutoCompute/ChangeCalculations/SetChangeCalculation.cs
1

2
namespace LLL.AutoCompute.ChangeCalculations;
3

4
public record class SetChangeCalculation<TElement>(
16✔
5
    bool incremental,
46✔
6
    IEqualityComparer<TElement>? comparer = null)
62✔
7
    : IChangeCalculation<IEnumerable<TElement>, SetChange<TElement>>
8
{
9
    public bool IsIncremental => incremental;
30✔
10
    public bool PreLoadEntities => true;
×
11
    public IEqualityComparer<TElement> Comparer {get;} = comparer ?? EqualityComparer<TElement>.Default;
16✔
12

13
    public SetChange<TElement> GetChange(IComputedValues<IEnumerable<TElement>> computedValues)
14
    {
15
        var original = computedValues.GetOriginalValue();
19✔
16
        var current = computedValues.GetCurrentValue();
19✔
17

18
        return new SetChange<TElement>
19✔
19
        {
19✔
20
            Removed = (original ?? []).Except(current ?? [], comparer).ToArray(),
19✔
21
            Added = (current ?? []).Except(original ?? [], comparer).ToArray()
19✔
22
        };
19✔
23
    }
24

25
    public bool IsNoChange(SetChange<TElement> result)
26
    {
27
        return result.Removed.Count == 0 && result.Added.Count == 0;
19✔
28
    }
29

30
    public SetChange<TElement> DeltaChange(SetChange<TElement> previous, SetChange<TElement> current)
31
    {
32
        return new SetChange<TElement>
2✔
33
        {
2✔
34
            Removed = (current.Removed ?? []).Except(previous.Removed ?? [], comparer)
2✔
35
                    .Concat((previous.Added ?? []).Except(current.Added ?? [], comparer))
2✔
36
                    .ToArray(),
2✔
37
            Added = (current.Added ?? []).Except(previous.Added ?? [], comparer)
2✔
38
                    .Concat((previous.Removed ?? []).Except(current.Removed ?? [], comparer))
2✔
39
                    .ToArray()
2✔
40
        };
2✔
41
    }
42

43
    public SetChange<TElement> ApplyChange(SetChange<TElement> value, SetChange<TElement> change)
44
    {
45
        return new SetChange<TElement>
×
46
        {
×
47
            Removed = value.Removed.Except(change.Added).Concat(change.Removed).ToArray(),
×
48
            Added = value.Added.Except(change.Removed).Concat(change.Added).ToArray()
×
UNCOV
49
        };
×
50
    }
51
}
52

UNCOV
53
public record SetChange<TElement>
×
54
{
55
    public required IReadOnlyCollection<TElement> Removed { get; init; }
51✔
56
    public required IReadOnlyCollection<TElement> Added { get; init; }
43✔
57
}
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