Skip to content

Commit 99a97c5

Browse files
committed
Moved InvokeAsync from IRenderedFragmentBase to IRenderedComponentBase. Closes #156
1 parent d5ebfbc commit 99a97c5

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/bunit.core/IRenderedComponentBase.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading.Tasks;
23
using Bunit.Rendering;
34

45
using Microsoft.AspNetCore.Components;
@@ -16,6 +17,13 @@ public interface IRenderedComponentBase<TComponent> : IRenderedFragmentBase wher
1617
/// </summary>
1718
TComponent Instance { get; }
1819

20+
/// <summary>
21+
/// Invokes the given <paramref name="callback"/> in the context of the associated <see cref="ITestRenderer"/>.
22+
/// </summary>
23+
/// <param name="callback"></param>
24+
/// <returns>A <see cref="Task"/> that will be completed when the action has finished executing.</returns>
25+
Task InvokeAsync(Action callback);
26+
1927
/// <summary>
2028
/// Render the component under test again.
2129
/// </summary>

src/bunit.core/IRenderedFragmentBase.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ public interface IRenderedFragmentBase
2727
/// <summary>
2828
/// Gets the <see cref="IServiceProvider"/> used when rendering the component.
2929
/// </summary>
30-
IServiceProvider Services { get; }
31-
32-
/// <summary>
33-
/// Invokes the given <paramref name="callback"/> in the context of the associated <see cref="ITestRenderer"/>.
34-
/// </summary>
35-
/// <param name="callback"></param>
36-
/// <returns>A <see cref="Task"/> that will be completed when the action has finished executing.</returns>
37-
Task InvokeAsync(Action callback);
30+
IServiceProvider Services { get; }
3831
}
3932
}

src/bunit.web/Rendering/RenderedComponent.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Threading.Tasks;
45
using Microsoft.AspNetCore.Components;
56

67
namespace Bunit.Rendering
@@ -16,6 +17,9 @@ public RenderedComponent(IServiceProvider services, int componentId, TComponent
1617
Instance = component;
1718
}
1819

20+
/// <inheritdoc/>
21+
public Task InvokeAsync(Action callback) => Renderer.Dispatcher.InvokeAsync(callback);
22+
1923
/// <inheritdoc/>
2024
public void Render() => SetParametersAndRender(ParameterView.Empty);
2125

src/bunit.web/Rendering/RenderedFragment.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ public IReadOnlyList<IDiff> GetChangesSinceFirstRender()
129129
return Nodes.CompareTo(_firstRenderNodes);
130130
}
131131

132-
/// <inheritdoc/>
133-
public Task InvokeAsync(Action callback) => Renderer.Dispatcher.InvokeAsync(callback);
134-
135132
private string RetrieveLatestMarkupFromRenderer() => Htmlizer.GetHtml(Renderer, ComponentId);
136133

137134
Task IRenderEventHandler.Handle(RenderEvent renderEvent)

0 commit comments

Comments
 (0)