-
I continue my tests of So first I will show the test for the @inherits AntDesignTestBase
@code {
class Model
{
public string Name { get; set; }
}
Model _model = new();
AntDesign.Form<Model> _form;
[Fact]
public void Form_EditContext_fires_OnFieldChange()
{
//Arrange
bool handlerExecuted = false;
Action<FieldChangedEventArgs> onFieldChanged = (e) => handlerExecuted = true;
var cut = Render<AntDesign.Form<Model>>(
@<AntDesign.Form @ref="@_form" Model="@_model"
OnFieldChanged="onFieldChanged"
ValidateOnChange="@true">
<AntDesign.FormItem Label="Name">
<AntDesign.Input @bind-Value=@context.Name/>
</AntDesign.FormItem>
</AntDesign.Form>
);
var input = cut.FindComponent<AntDesign.Input<string>>(); //<= getting the Input component to manipulate it directly
//Act
input.Find("input").Input("newValue");
input.Find("input").KeyUp(String.Empty);
//Assert
input.WaitForState(() => input.Instance.Value is not null);
handlerExecuted.Should().BeTrue();
}
} A bit of introduction is needed here - I cannot just use So, I created this: @inherits AntDesignTestBase
@code {
[Fact]
public void Input_Debounce_sets_value()
{
//Arrange
string value = null;
var cut = Render<AntDesign.Input<string>>(@<AntDesign.Input @bind-Value=@value/>);
//Act
cut.Find("input").Input("newValue");
cut.Find("input").KeyUp(String.Empty);
//Assert
cut.WaitForState(() => cut.Instance.Value is not null);
cut.Instance.Value.Should().Be("newValue");
}
} To my surprise, I got this error
I run the debugger. I see that the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hi @anddrzejb, A few questions:
|
Beta Was this translation helpful? Give feedback.
Hi @anddrzejb,
A few questions:
AntDesign.Input<string>
is a child component ofAntDesign.Form<Model>
and in the other test, it is the main component under test?Input_Debounce_sets_value
fail consistently every time you run it, or is it random?