Closed jpiell closed 4 years ago
What version are you on? Can you include the stack trace? What is the lookup component? Please share it if possible.
5.1
System.InvalidOperationException
HResult=0x80131509
Message=The render handle is not yet assigned.
Source=Microsoft.AspNetCore.Components
StackTrace:
at Microsoft.AspNetCore.Components.RenderHandle.ThrowNotInitialized()
at Microsoft.AspNetCore.Components.RenderHandle.Render(RenderFragment
renderFragment)
at Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
at
Telerik.Blazor.Components.TelerikRootComponentBase.AddFragment(RenderFragment
renderFunction)
at
Telerik.Blazor.Components.RootComponent.TelerikRootComponentFragmentBase.OnInitializedAsync()
at
Microsoft.AspNetCore.Components.ComponentBase.1..ctor(ITestContext testContext, RenderFragment renderFragment) at Egil.RazorComponents.Testing.RenderedComponent
1..ctor(ITestContext
testContext, IReadOnlyList`1 parameters)
at
Egil.RazorComponents.Testing.TestContext.RenderComponentTComponent
at
TIPS.ComponentTests.CommonComponentTests.LookupRendersCorrectlySelectGridItem()
in
C:\Projects\TIPS\ComponentTests\CommonComponentTests\ComponentTests.cs:line
257
This exception was originally thrown at this call stack: [External Code]
TIPS.ComponentTests.CommonComponentTests.LookupRendersCorrectlySelectGridItem() in ComponentTests.cs
On Fri, Jan 24, 2020 at 12:11 PM Egil Hansen notifications@github.com wrote:
What version are you on, and can you include the stack trace?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/egil/razor-components-testing-library/issues/45?email_source=notifications&email_token=AHE7FB6OEV2VMEFZVH7M363Q7MOKPA5CNFSM4KLJALP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJ3OTBY#issuecomment-578218375, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHE7FBY7JPITHNHAOGG3DMTQ7MOKPANCNFSM4KLJALPQ .
Hmm, sorry, can't see what's going on. Can you create a minimal example that shows the problem?
I am closing this for now. If this is still an issue, just get back to me with a minimal example.
Hi Egil,
Sorry I got tied up in other things.
Attached is an example.
Thanks,
Keep it closed. It was my error.
Nope = I still need help. The problem occurs if the RenderComponent passes the component and not the grid
Ok now I did figure it out.
The render should look like this:
var cut = RenderComponent<TelerikRootComponent>(
ChildContent<FetchData>(
));
Hi @jpiell
Good. Great it worked out. If you want to make it a bit easier to test your components the rely on Teleriks components, you can add a small helper method like this in your test class:
private IRenderedComponent<TComponent> RenderComponentInTelerikRoot<TComponent>(params ComponentParameter[] parameters) where TComponent : class, IComponent
{
return RenderComponent<TelerikRootComponent>(ChildContent<TComponent>(parameters));
}
Then you can do simply do a:
var cut = RenderComponentInTelerikRoot<FetchData>();
Nice!
From: Egil Hansen notifications@github.com Sent: Thursday, January 30, 2020 4:43 PM To: egil/razor-components-testing-library razor-components-testing-library@noreply.github.com Cc: jpiell jpiell@gmail.com; Mention mention@noreply.github.com Subject: Re: [egil/razor-components-testing-library] The render handle is not yet assigned. (#45)
Hi @jpiell https://github.com/jpiell
Good. Great it worked out. If you want to make it a bit easier to test your components the rely on Teleriks components, you can add a small helper method like this in your test class:
private IRenderedComponent
Then you can do simply do a:
var cut = RenderComponentInTelerikRoot
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/egil/razor-components-testing-library/issues/45?email_source=notifications&email_token=AHE7FB4JFNPO4IAKMKCPFD3RANCXTA5CNFSM4KLJALP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKMVKBI#issuecomment-580474117 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AHE7FB32RY2NI74O7KWFKKDRANCXTANCNFSM4KLJALPQ . https://github.com/notifications/beacon/AHE7FB2U5FSMDJTDSEJ2EYTRANCXTA5CNFSM4KLJALP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKMVKBI.gif
The same error happens to me when I try to add a simple menu item dynamically. I am using Radzen.Blazor v3.9.6.
I hope we can get a more stable version of Radzen components for Blazor soon in https://github.com/radzenhq/radzen-blazor.
@RafaelMeloTrakx you really need to provide a lot more details for me to help. Ideally a minimal project that has just enough code to reproduce your problem.
I am having this issue it has been very challenging.
I have included a minimal example to show what has been happening.
@Modricagon you are new'ing up the Modal
component directly. That is not supported by Blazor and will result in the exception you are seeing. This is not really a bUnit thing, this is fundamental to how Blazor works.
@Modricagon you are new'ing up the
Modal
component directly. That is not supported by Blazor and will result in the exception you are seeing. This is not really a bUnit thing, this is fundamental to how Blazor works.
Thanks for this! This really helped me understand what I was doing wrong. Instead I rendered the Modal component first with the "var cut = ctx.RenderComponent
Thanks so much issue resolved.
@Modricagon - I have this exact same issue - any chance you could expand on what you did to resolve it please? i.e. How did you change:
[Test]
public void Test1()
{
ctx.RenderComponent<Wizard>(parameters =>
{
parameters.Add(p => p.ModalInstance, new Modal());
});
}
I am getting an exception when trying to render my component.
Any directional help would be appreciated.
Here is my test: