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

loresoft / EntityChange / 13417967502

19 Feb 2025 04:51PM UTC coverage: 45.43% (+5.7%) from 39.697%
13417967502

push

github

pwelter34
fix failing test

287 of 726 branches covered (39.53%)

Branch coverage included in aggregate %.

563 of 1145 relevant lines covered (49.17%)

73.33 hits per line

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

64.29
/src/EntityChange/Extensions/EnumerableExtensions.cs
1
namespace EntityChange.Extensions;
2

3
/// <summary>
4
/// Extension methods for <see cref="IEnumerable{T}"/>
5
/// </summary>
6
public static class EnumerableExtensions
7
{
8
    /// <summary>
9
    /// Converts an IEnumerable of values to a delimited string.
10
    /// </summary>
11
    /// <typeparam name="T">
12
    /// The type of objects to delimit.
13
    /// </typeparam>
14
    /// <param name="values">
15
    /// The IEnumerable string values to convert.
16
    /// </param>
17
    /// <param name="delimiter">
18
    /// The delimiter.
19
    /// </param>
20
    /// <returns>
21
    /// A delimited string of the values.
22
    /// </returns>
23
    public static string ToDelimitedString<T>(this IEnumerable<T?> values, string? delimiter = ",")
24
        => string.Join(delimiter ?? ",", values);
×
25

26
    /// <summary>
27
    /// Converts an IEnumerable of values to a delimited string.
28
    /// </summary>
29
    /// <param name="values">The IEnumerable string values to convert.</param>
30
    /// <param name="delimiter">The delimiter.</param>
31
    /// <returns>A delimited string of the values.</returns>
32
    public static string ToDelimitedString(this IEnumerable<string?> values, string? delimiter = ",")
33
        => string.Join(delimiter ?? ",", values);
×
34

35
    /// <summary>
36
    /// Compares the specified existing and current lists returning the delta between them.
37
    /// </summary>
38
    /// <typeparam name="TItem">The type of the item.</typeparam>
39
    /// <param name="existing">The existing list of items.</param>
40
    /// <param name="current">The new and current list of items.</param>
41
    /// <param name="comparer">The comparer the <see cref="IEqualityComparer{T}"/> used to compare the items.</param>
42
    /// <returns>The <see cref="Delta{TItem}"/> result of two lists.</returns>
43
    /// <exception cref="ArgumentNullException">when <paramref name="existing"/> or <paramref name="current"/> lists are null.</exception>
44
    public static Delta<TItem> DeltaCompare<TItem>(this IEnumerable<TItem> existing, IEnumerable<TItem> current, IEqualityComparer<TItem>? comparer = null)
45
    {
46
        if (existing is null)
3!
47
            throw new ArgumentNullException(nameof(existing));
×
48

49
        if (current is null)
3!
50
            throw new ArgumentNullException(nameof(current));
×
51

52
        comparer ??= EqualityComparer<TItem>.Default;
3✔
53

54
        var existingList = existing.ToList();
3✔
55
        var currentList = current.ToList();
3✔
56

57
        var matched = existingList.Intersect(currentList, comparer);
3✔
58
        var created = currentList.Except(existingList, comparer);
3✔
59
        var deleted = existingList.Except(currentList, comparer);
3✔
60

61
        return new Delta<TItem>
3✔
62
        {
3✔
63
            Created = created,
3✔
64
            Deleted = deleted,
3✔
65
            Matched = matched
3✔
66
        };
3✔
67
    }
68
}
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