Skip to content

Commit e04e331

Browse files
committed
Added missing code documentation
1 parent 751c43d commit e04e331

6 files changed

Lines changed: 65 additions & 1 deletion

File tree

src/Asserting/ShouldBeTextChangeAssertExtensions.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@ namespace Egil.RazorComponents.Testing.Asserting
1515
/// </summary>
1616
public static class ShouldBeTextChangeAssertExtensions
1717
{
18+
/// <summary>
19+
/// Verifies that a list of diffs contains only a single change, and that change is a change to a text node.
20+
/// </summary>
21+
/// <param name="diffs">The list of diffs to verify against.</param>
22+
/// <param name="expectedChange">The expected text change.</param>
23+
/// <param name="userMessage">A custom error message to show if the verification fails.</param>
1824
public static void ShouldHaveSingleTextChange(this IReadOnlyList<IDiff> diffs, string expectedChange, string? userMessage = null)
1925
{
2026
DiffAssertExtensions.ShouldHaveSingleChange(diffs).ShouldBeTextChange(expectedChange, userMessage);
2127
}
2228

29+
/// <summary>
30+
/// Verifies that a diff is a change to a text node.
31+
/// </summary>
32+
/// <param name="actualChange">The diff to verify.</param>
33+
/// <param name="expectedChange">The expected text change.</param>
34+
/// <param name="userMessage">A custom error message to show if the verification fails.</param>
2335
public static void ShouldBeTextChange(this IDiff actualChange, string expectedChange, string? userMessage = null)
2436
{
2537
if (actualChange is null) throw new ArgumentNullException(nameof(actualChange));
@@ -32,12 +44,24 @@ public static void ShouldBeTextChange(this IDiff actualChange, string expectedCh
3244
ShouldBeTextChange(actualChange, expected, userMessage);
3345
}
3446

47+
/// <summary>
48+
/// Verifies that a diff is a change to a text node.
49+
/// </summary>
50+
/// <param name="actualChange">The diff to verify.</param>
51+
/// <param name="expectedChange">The rendered fragment containing the expected text change.</param>
52+
/// <param name="userMessage">A custom error message to show if the verification fails.</param>
3553
public static void ShouldBeTextChange(this IDiff actualChange, IRenderedFragment expectedChange, string? userMessage = null)
3654
{
3755
if (expectedChange is null) throw new ArgumentNullException(nameof(expectedChange));
3856
ShouldBeTextChange(actualChange, expectedChange.GetNodes(), userMessage);
3957
}
4058

59+
/// <summary>
60+
/// Verifies that a diff is a change to a text node.
61+
/// </summary>
62+
/// <param name="actualChange">The diff to verify.</param>
63+
/// <param name="expectedChange">The node list containing the expected text change.</param>
64+
/// <param name="userMessage">A custom error message to show if the verification fails.</param>
4165
public static void ShouldBeTextChange(this IDiff actualChange, INodeList expectedChange, string? userMessage = null)
4266
{
4367
if (actualChange is null) throw new ArgumentNullException(nameof(actualChange));

src/Components/ComponentUnderTest.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55
namespace Egil.RazorComponents.Testing
66
{
7-
7+
/// <summary>
8+
/// Represents a component that can be added inside a <see cref="Fixture"/>,
9+
/// where a component under test can be defined as the child content.
10+
/// </summary>
811
public class ComponentUnderTest : FragmentBase
912
{
13+
/// <inheritdoc />
1014
public override Task SetParametersAsync(ParameterView parameters)
1115
{
1216
var result = base.SetParametersAsync(parameters);

src/Components/Fragment.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22

33
namespace Egil.RazorComponents.Testing
44
{
5+
/// <summary>
6+
/// Represents a component that can be added inside a <see cref="Fixture"/>, whose content
7+
/// can be accessed in Razor-based test.
8+
/// </summary>
59
public class Fragment : FragmentBase
610
{
11+
/// <summary>
12+
/// Gets or sets the id of the fragment. The <see cref="Id"/> can be used to retrieve
13+
/// the fragment from a <see cref="IRazorTestContext.GetFragment(string)"/>.
14+
/// </summary>
715
[Parameter] public string Id { get; set; } = string.Empty;
816
}
917
}

src/Components/FragmentBase.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@
44

55
namespace Egil.RazorComponents.Testing
66
{
7+
/// <summary>
8+
/// Represents a fragment that can be used in <see cref="SnapshotTest"/> or <see cref="Fixture"/>.
9+
/// </summary>
710
public abstract class FragmentBase : IComponent
811
{
12+
/// <summary>
13+
/// Gets or sets the child content of the fragment.
14+
/// </summary>
915
[Parameter] public RenderFragment ChildContent { get; set; } = default!;
1016

17+
/// <inheritdoc />
1118
public void Attach(RenderHandle renderHandle) { }
1219

20+
/// <inheritdoc />
1321
public virtual Task SetParametersAsync(ParameterView parameters)
1422
{
1523
parameters.SetParameterProperties(this);

src/Diffing/BlazorDiffingHelpers.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33

44
namespace Egil.RazorComponents.Testing.Diffing
55
{
6+
/// <summary>
7+
/// Blazor Dffing Helpers
8+
/// </summary>
69
public static class BlazorDiffingHelpers
710
{
11+
/// <summary>
12+
/// Represents a diffing filter that removes all special Blazor attributes added by the <see cref="TestRenderer"/>/<see cref="Htmlizer"/>.
13+
/// </summary>
814
public static FilterDecision BlazorEventHandlerIdAttrFilter(in AttributeComparisonSource attrSource, FilterDecision currentDecision)
915
{
1016
if (currentDecision == FilterDecision.Exclude) return currentDecision;

src/Diffing/DiffMarkupFormatter.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace Egil.RazorComponents.Testing.Diffing
77
{
8+
/// <summary>
9+
/// A markup formatter, that skips any special Blazor attributes added by the <see cref="TestRenderer"/>/<see cref="Htmlizer"/>.
10+
/// </summary>
811
public class DiffMarkupFormatter : IMarkupFormatter
912
{
1013
private readonly IMarkupFormatter _formatter = new PrettyMarkupFormatter()
@@ -13,14 +16,22 @@ public class DiffMarkupFormatter : IMarkupFormatter
1316
Indentation = " "
1417
};
1518

19+
/// <inheritdoc />
1620
public string Attribute(IAttr attribute)
1721
=> Htmlizer.IsBlazorAttribute(attribute?.Name ?? string.Empty)
1822
? string.Empty
1923
: _formatter.Attribute(attribute);
2024

25+
/// <inheritdoc />
2126
public string CloseTag(IElement element, bool selfClosing) => _formatter.CloseTag(element, selfClosing);
27+
28+
/// <inheritdoc />
2229
public string Comment(IComment comment) => _formatter.Comment(comment);
30+
31+
/// <inheritdoc />
2332
public string Doctype(IDocumentType doctype) => _formatter.Doctype(doctype);
33+
34+
/// <inheritdoc />
2435
public string OpenTag(IElement element, bool selfClosing)
2536
{
2637
if(element is null) throw new ArgumentNullException(nameof(element));
@@ -39,7 +50,10 @@ public string OpenTag(IElement element, bool selfClosing)
3950
return result;
4051
}
4152

53+
/// <inheritdoc />
4254
public string Processing(IProcessingInstruction processing) => _formatter.Processing(processing);
55+
56+
/// <inheritdoc />
4357
public string Text(ICharacterData text) => _formatter.Text(text);
4458
}
4559
}

0 commit comments

Comments
 (0)