From f21db7937698fb98eb79a88103806458b9ac2b85 Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Tue, 21 Nov 2023 20:54:07 +0100 Subject: [PATCH] docs: Add limitation for rendering a RenderFragment --- .../passing-parameters-to-components.md | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/site/docs/providing-input/passing-parameters-to-components.md b/docs/site/docs/providing-input/passing-parameters-to-components.md index ae0de5489..522638aaf 100644 --- a/docs/site/docs/providing-input/passing-parameters-to-components.md +++ b/docs/site/docs/providing-input/passing-parameters-to-components.md @@ -442,6 +442,30 @@ The solution is to inherit from bUnits `TestContext` instead, i.e.: } ``` +## Limitations of rendering a `RenderFragment` inside a test + +When rendering a `RenderFragment` using the method, the created is static. This means that it will not re-render even if events are triggered. +```razor +@inherits TestContext + +@code { + [Fact] + public void Button_clicked_string_gets_updated() + { + var output = string.Empty; + var cut = Render(@); + + cut.Find("button").Click(); + + // This will pass, as events are triggered and the function get executed + output.ShouldBe("Success"); + + // This will fail, as the markup will not get updated + cut.Find("button").TextContent.ShouldBe("Success"); + } +} +``` + ## Further Reading -