System.InvalidOperationException: 'The render handle is not yet assigned.' when trying to change
It is either my code or a bug. I can't get around it.
// Test code
var cut = ctx.Render(
@
var testCut = cut.Find("#TestCountry");
testCut.Change("UnitedStates"); <---- System.InvalidOperationException: 'The render handle is not yet assigned.'
// in component line that gets exception
builder.AddAttribute(5, "onchange", EventCallback.Factory.CreateBinder
Results in this output: System.InvalidOperationException: 'The render handle is not yet assigned.'
Expected behavior: I would expect it to work?
Version info:
- bUnit version: latest 1.38.5
- .NET Runtime and Blazor version: 9.0
- OS type and version: Windows 11
Additional context: It states from what I can find is that most likely component not rendered? But I did Render as can see above? Did I do it wrong?
No that is somewhat a known limitation.
Try using @inherits TestContext in your razor file and use this.
I am on mobile and have to check the link in the docs where this explained
Here the link to the docs: https://bunit.dev/docs/providing-input/passing-parameters-to-components.html?tabs=csharp#getting-an-invalidoperationexception
I will close the issue, as it is documented. Let me know if it doesn't resolve your issue
It did
Thanks, Brett
On Feb 11, 2025, at 3:14 AM, Steven Giesel @.***> wrote:
I will close the issue, as it is documented. Let me know if it doesn't resolve your issue
— Reply to this email directly, view it on GitHubhttps://github.com/bUnit-dev/bUnit/issues/1669#issuecomment-2650084602, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BMWBLSPEBA6HHNWQ26677LD2PGWPZAVCNFSM6AAAAABWX7HVWKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJQGA4DINRQGI. You are receiving this because you authored the thread.Message ID: @.***>