Skip to content

Commit 68a4da2

Browse files
committed
fix: improve exception message in UnknownEventHandlerIdException
1 parent a21770d commit 68a4da2

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/bunit.core/Rendering/UnknownEventHandlerIdException.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ private UnknownEventHandlerIdException(SerializationInfo serializationInfo, Stre
2020

2121
private static string CreateMessage(ulong eventHandlerId, EventFieldInfo fieldInfo)
2222
=> $"There is no event handler with ID '{eventHandlerId}' associated with the '{fieldInfo.FieldValue}' event " +
23-
"in the current render tree. This can happen, for example, when using cut.FindAll(), and calling event trigger methods " +
24-
"on the found elements after a re-render of the render tree. The workaround is to use re-issue the cut.FindAll() after " +
25-
"each render of a component, this ensures you have the latest version of the render tree and DOM tree available in your test code.";
23+
$"in the current render tree.{Environment.NewLine}{Environment.NewLine}" +
24+
$"This can happen, for example, when using `cut.FindAll()`, and calling event trigger methods " +
25+
"on the found elements after a re-render of the render tree. The workaround is to use re-issue the `cut.FindAll()` call after " +
26+
$"each render of a component, this ensures you have the latest version of the render tree and DOM tree available in your test code.{Environment.NewLine}{Environment.NewLine}" +
27+
$"This can happen with code like this, `cut.Find(\"button\").Click()`, where the buttons event handler can be removed " +
28+
$"between the time button is found with the Find method and the Click method is triggered. The workaround is to use " +
29+
$"wrap the Find and Click method calls in InvokeAsync, i.e. `cut.InvokeAsync(() => cut.Find(\"button\").Click());`. " +
30+
$"This ensures that there are no changes to the DOM between Find method and the Click method calls.";
2631
}

0 commit comments

Comments
 (0)