-
|
I'm implementing an integration test with bUnit on a Blazor wasm component who use TelerikTextBox component. Example: cs: In the test method i can find and set the TelerikTextBox value with: but it not bind the property How to reach my goal? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 5 replies
-
|
Hey @Gambero81. If you have a component like this: <input @bind-value="@UserName"/>
@code {
public string UserName { get; set; } = "";
}With the following test: var cut = RenderComponent<MyComponent>();
cut.Find("input").Change("test"); // Change the value of the input field
var userName = cut.Instance.UserName; // Will be "test"As you can see we are leveraging the cut.FindComponents<TelerikTextBox>().Find("#txtUserName").Change("My TextBox Value");We need to trigger to Blazor Pipeline. In our case we do this with |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @linkdotnet, using I solved using the |
Beta Was this translation helpful? Give feedback.
-
|
Hey @Gambero81 I am not sure why you would need the If your issue is sorted, could you close it? Still we can discuss the |
Beta Was this translation helpful? Give feedback.
-
|
@Gambero81 Have you added to the test:
These are required for all Telerik Components to work properly. Here is a sample: https://github.com/telerik/blazor-ui/blob/master/testing/bUnit-justmock/Telerik.Blazor.BUnit.JustMock/DemoSample/ExampleModelTest.cs |
Beta Was this translation helpful? Give feedback.
-
|
@linkdotnet yes, using @EdCharbeneau yes i added if i use
i get the
If i not call |
Beta Was this translation helpful? Give feedback.
-
|
Hi all, I'm converting this to a QA discussion as it does not seem to be an issue with bUnit. |
Beta Was this translation helpful? Give feedback.
-
|
Hey @Gambero81 yes calling I am not sure if getting the instance of the Telerik component via: For me it would be helpful if you can post a small and minimal example of your problem. |
Beta Was this translation helpful? Give feedback.
-
|
I have arranged a little bit of code to reply the issue (nb. The Razor page: Code behind: User model: Test method: |
Beta Was this translation helpful? Give feedback.
-
|
Hey @Gambero81 Let's unwrap that a bit and I guess I spotted the issue. The interesting bit is that: //Submit form
cut.Find("#save-item-button").Click();
// User obj is not binded correctly
var userObj = cut.Instance.User;So the What you want to do here is awaiting some kind of state change which indicates your async method is done. cut.WaitForState(() => cut.Find(".validation-result").TextContent == "OK");
var userObj = cut.Instance.User;More information in the official documentation. Another smaller design note: You don't have to wrap your whole test in a try-catch block. If there is any exception thrown from the usercode, the test will fail anyway with the whole stack-trace. Therefore this adds just unnecessary boiler plate code. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @linkdotnet, I have updated the code sample, the problem still remain even without an async call, i have updated the sample with a syncro call updating the statement |
Beta Was this translation helpful? Give feedback.
-
|
@linkdotnet call setting a breakpoint in |
Beta Was this translation helpful? Give feedback.
-
|
Finally i solved using |
Beta Was this translation helpful? Give feedback.

Finally i solved using
SetParameterAndRenderto resetDebouceDelayfor allTelerikTextBoxinside the component under test: