• 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

0.0
/src/EntityChange/HtmlFormatter.cs
1
using System.Text;
2

3
namespace EntityChange;
4

5
/// <summary>
6
/// Format changes in HTML format.
7
/// </summary>
8
public class HtmlFormatter : IChangeFormatter
9
{
10
    /// <summary>
11
    /// Gets or sets the header template.
12
    /// </summary>
13
    /// <value>
14
    /// The header template.
15
    /// </value>
16
    public string HeaderTemplate { get; set; } = "<ul>";
×
17

18
    /// <summary>
19
    /// Gets or sets the footer template.
20
    /// </summary>
21
    /// <value>
22
    /// The footer template.
23
    /// </value>
24
    public string FooterTemplate { get; set; } = "</ul>";
×
25

26
    /// <summary>
27
    /// Gets or sets the operation add template.
28
    /// </summary>
29
    /// <value>
30
    /// The operation add template.
31
    /// </value>
32
    public string OperationAddTemplate { get; set; } = "<li>Added <span>{CurrentFormatted}</span> to <span>{DisplayName}</span></li>";
×
33

34
    /// <summary>
35
    /// Gets or sets the operation remove template.
36
    /// </summary>
37
    /// <value>
38
    /// The operation remove template.
39
    /// </value>
40
    public string OperationRemoveTemplate { get; set; } = "<li>Removed <span>{OriginalFormatted}</span> from <span>{DisplayName}</span></li>";
×
41

42
    /// <summary>
43
    /// Gets or sets the operation replace template.
44
    /// </summary>
45
    /// <value>
46
    /// The operation replace template.
47
    /// </value>
48
    public string OperationReplaceTemplate { get; set; } = "<li>Changed <span>{DisplayName}</span> from <span>{OriginalFormatted}</span> to <span>{CurrentFormatted}</span></li>";
×
49

50

51

52
    /// <summary>
53
    /// Create a readable change report.
54
    /// </summary>
55
    /// <param name="changes">The changes to format.</param>
56
    /// <returns>
57
    /// A string representing the <paramref name="changes" />.
58
    /// </returns>
59
    public string Format(IReadOnlyList<ChangeRecord> changes)
60
    {
61
        if (changes is null)
×
62
            throw new ArgumentNullException(nameof(changes));
×
63

64
        var builder = StringBuilderCache.Acquire();
×
65
        builder.AppendLine(HeaderTemplate ?? string.Empty);
×
66

67
        foreach (var change in changes)
×
68
        {
69
            string template;
70
            if (change.Operation == ChangeOperation.Add)
×
71
                template = OperationAddTemplate;
×
72
            else if (change.Operation == ChangeOperation.Remove)
×
73
                template = OperationRemoveTemplate;
×
74
            else
75
                template = OperationReplaceTemplate;
×
76

77
            var line = NameFormatter.FormatName(template, change);
×
78
            builder.AppendLine(line);
×
79
        }
80

81
        builder.AppendLine(FooterTemplate ?? string.Empty);
×
82

83
        return StringBuilderCache.ToString(builder);
×
84
    }
85
}
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