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

loresoft / EntityChange / 8912024321

01 May 2024 04:29PM UTC coverage: 39.608% (+1.4%) from 38.228%
8912024321

push

github

pwelter34
fix symbol build

237 of 731 branches covered (32.42%)

Branch coverage included in aggregate %.

571 of 1309 relevant lines covered (43.62%)

60.5 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
        var builder = new StringBuilder();
×
62
        builder.AppendLine(HeaderTemplate ?? string.Empty);
×
63

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

74
            var line = NameFormatter.Format(template, change);
×
75
            builder.AppendLine(line);
×
76
        }
77

78
        builder.AppendLine(FooterTemplate ?? string.Empty);
×
79
        return builder.ToString();
×
80
    }
81
}
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

© 2025 Coveralls, Inc