bUnit icon indicating copy to clipboard operation
bUnit copied to clipboard

System.InvalidOperationException: 'The render handle is not yet assigned.' when trying to change

Open bfmbrett opened this issue 1 year ago • 4 comments

It is either my code or a bug. I can't get around it.

// Test code var cut = ctx.Render( @ <EnumInputSelect Id="TestCountry" @bind-Value="TestData.TestCountry" /> );

    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(this, value => CurrentValueAsString = value, CurrentValueAsString ?? "", null));

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?

bfmbrett avatar Feb 08 '25 19:02 bfmbrett

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

linkdotnet avatar Feb 08 '25 19:02 linkdotnet

Here the link to the docs: https://bunit.dev/docs/providing-input/passing-parameters-to-components.html?tabs=csharp#getting-an-invalidoperationexception

linkdotnet avatar Feb 08 '25 19:02 linkdotnet

I will close the issue, as it is documented. Let me know if it doesn't resolve your issue

linkdotnet avatar Feb 11 '25 08:02 linkdotnet

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: @.***>

bfmbrett avatar Feb 11 '25 12:02 bfmbrett