Skip to content

Commit 6b6a80e

Browse files
committed
fix: make async versions of WaitForX methods public
fixes #1769
1 parent 3ee85a1 commit 6b6a80e

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/bunit/Extensions/WaitForHelpers/RenderedComponentWaitForHelperExtensions.WaitForElement.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static IReadOnlyList<IElement> WaitForElements<TComponent>(this IRendered
9191
/// <param name="cssSelector">The CSS selector to use to search for the element.</param>
9292
/// <exception cref="WaitForFailedException">Thrown if no elements is found matching the <paramref name="cssSelector"/> within the default timeout. See the inner exception for details.</exception>
9393
/// <returns>The <see cref="IElement"/>.</returns>
94-
internal static Task<IElement> WaitForElementAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector)
94+
public static Task<IElement> WaitForElementAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector)
9595
where TComponent : IComponent => WaitForElementCoreAsync(renderedComponent, cssSelector, timeout: null);
9696

9797
/// <summary>
@@ -103,7 +103,7 @@ internal static Task<IElement> WaitForElementAsync<TComponent>(this IRenderedCom
103103
/// <param name="timeout">The maximum time to wait for the element to appear.</param>
104104
/// <exception cref="WaitForFailedException">Thrown if no elements is found matching the <paramref name="cssSelector"/> within the default timeout. See the inner exception for details.</exception>
105105
/// <returns>The <see cref="IElement"/>.</returns>
106-
internal static Task<IElement> WaitForElementAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector, TimeSpan timeout)
106+
public static Task<IElement> WaitForElementAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector, TimeSpan timeout)
107107
where TComponent : IComponent
108108
=> WaitForElementCoreAsync(renderedComponent, cssSelector, timeout: timeout);
109109

@@ -116,7 +116,7 @@ internal static Task<IElement> WaitForElementAsync<TComponent>(this IRenderedCom
116116
/// <param name="matchElementCount">The exact number of elements to that the <paramref name="cssSelector"/> should match.</param>
117117
/// <exception cref="WaitForFailedException">Thrown if no elements is found matching the <paramref name="cssSelector"/> within the default timeout.</exception>
118118
/// <returns>The <see cref="IReadOnlyList{IElement}"/>.</returns>
119-
internal static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector, int matchElementCount)
119+
public static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector, int matchElementCount)
120120
where TComponent : IComponent
121121
=> WaitForElementsCoreAsync(renderedComponent, cssSelector, matchElementCount: matchElementCount, timeout: null);
122122

@@ -129,7 +129,7 @@ internal static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(t
129129
/// <param name="timeout">The maximum time to wait for elements to appear.</param>
130130
/// <exception cref="WaitForFailedException">Thrown if no elements is found matching the <paramref name="cssSelector"/> within the default timeout.</exception>
131131
/// <returns>The <see cref="IReadOnlyList{IElement}"/>.</returns>
132-
internal static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector, TimeSpan timeout)
132+
public static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector, TimeSpan timeout)
133133
where TComponent : IComponent
134134
=> WaitForElementsCoreAsync(renderedComponent, cssSelector, matchElementCount: null, timeout: timeout);
135135

@@ -143,7 +143,7 @@ internal static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(t
143143
/// <param name="timeout">The maximum time to wait for elements to appear.</param>
144144
/// <exception cref="WaitForFailedException">Thrown if no elements is found matching the <paramref name="cssSelector"/> within the default timeout.</exception>
145145
/// <returns>The <see cref="IReadOnlyList{IElement}"/>.</returns>
146-
internal static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector, int matchElementCount, TimeSpan timeout)
146+
public static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector, int matchElementCount, TimeSpan timeout)
147147
where TComponent : IComponent
148148
=> WaitForElementsCoreAsync(renderedComponent, cssSelector, matchElementCount: matchElementCount, timeout: timeout);
149149

@@ -155,7 +155,7 @@ internal static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(t
155155
/// <param name="cssSelector">The CSS selector to use to search for elements.</param>
156156
/// <exception cref="WaitForFailedException">Thrown if no elements is found matching the <paramref name="cssSelector"/> within the default timeout.</exception>
157157
/// <returns>The <see cref="IReadOnlyList{IElement}"/>.</returns>
158-
internal static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector)
158+
public static Task<IReadOnlyList<IElement>> WaitForElementsAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector)
159159
where TComponent : IComponent
160160
=> WaitForElementsCoreAsync<TComponent>(renderedComponent, cssSelector, matchElementCount: null, timeout: null);
161161

@@ -166,7 +166,7 @@ private static IElement WaitForElementCore<TComponent>(this IRenderedComponent<T
166166

167167
try
168168
{
169-
return waiter.WaitTask.GetAwaiter().GetResult();
169+
return waiter.WaitTask.ConfigureAwait(false).GetAwaiter().GetResult();
170170
}
171171
catch (AggregateException e) when (e.InnerExceptions.Count == 1)
172172
{
@@ -196,7 +196,7 @@ private static IReadOnlyList<IElement> WaitForElementsCore<TComponent>(
196196

197197
try
198198
{
199-
return waiter.WaitTask.GetAwaiter().GetResult();
199+
return waiter.WaitTask.ConfigureAwait(false).GetAwaiter().GetResult();
200200
}
201201
catch (AggregateException e) when (e.InnerExceptions.Count == 1)
202202
{

src/bunit/Extensions/WaitForHelpers/RenderedComponentWaitForHelperExtensions.WaitForState.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static void WaitForState<TComponent>(this IRenderedComponent<TComponent>
3030

3131
try
3232
{
33-
waiter.WaitTask.GetAwaiter().GetResult();
33+
waiter.WaitTask.ConfigureAwait(false).GetAwaiter().GetResult();
3434
}
3535
catch (AggregateException e) when (e.InnerExceptions.Count == 1)
3636
{
@@ -49,11 +49,10 @@ public static void WaitForState<TComponent>(this IRenderedComponent<TComponent>
4949
/// <param name="statePredicate">The predicate to invoke after each render, which must returns <c>true</c> when the desired state has been reached.</param>
5050
/// <param name="timeout">The maximum time to wait for the desired state.</param>
5151
/// <exception cref="WaitForFailedException">Thrown if the <paramref name="statePredicate"/> throw an exception during invocation, or if the timeout has been reached. See the inner exception for details.</exception>
52-
internal static async Task WaitForStateAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, Func<bool> statePredicate, TimeSpan? timeout = null)
52+
public static async Task WaitForStateAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, Func<bool> statePredicate, TimeSpan? timeout = null)
5353
where TComponent : IComponent
5454
{
5555
using var waiter = new WaitForStateHelper<TComponent>(renderedComponent, statePredicate, timeout);
56-
5756
await waiter.WaitTask;
5857
}
5958

@@ -75,7 +74,7 @@ public static void WaitForAssertion<TComponent>(this IRenderedComponent<TCompone
7574

7675
try
7776
{
78-
waiter.WaitTask.GetAwaiter().GetResult();
77+
waiter.WaitTask.ConfigureAwait(false).GetAwaiter().GetResult();
7978
}
8079
catch (AggregateException e) when (e.InnerExceptions.Count == 1)
8180
{
@@ -94,11 +93,10 @@ public static void WaitForAssertion<TComponent>(this IRenderedComponent<TCompone
9493
/// <param name="timeout">The maximum time to attempt the verification.</param>
9594
/// <exception cref="WaitForFailedException">Thrown if the timeout has been reached. See the inner exception to see the captured assertion exception.</exception>
9695
[AssertionMethod]
97-
internal static async Task WaitForAssertionAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, Action assertion, TimeSpan? timeout = null)
96+
public static async Task WaitForAssertionAsync<TComponent>(this IRenderedComponent<TComponent> renderedComponent, Action assertion, TimeSpan? timeout = null)
9897
where TComponent : IComponent
9998
{
10099
using var waiter = new WaitForAssertionHelper<TComponent>(renderedComponent, assertion, timeout);
101-
102100
await waiter.WaitTask;
103101
}
104102
}

0 commit comments

Comments
 (0)