public async Task TestMethod() { using var ctx = new Bunit.TestContext(); ctx.Services.AddSyncfusionBlazor(); // Render your component IRenderedComponent<Component1> cut = ctx.RenderComponent<Component1>(); // Find the SfDropDownList component var DropDownInput = cut.FindComponent<SfDropDownList<string, Country>>(); DropDownInput.SetParametersAndRender(param => param .AddChildContent<DropDownListEvents<string, Country>>(events => events .Add(e => e.ValueChange, (ChangeEventArgs<string, Country> args) => { cut.Instance.DropVal = args.Value; }) )); DropDownInput.SetParametersAndRender(("Value", "Cameroon")); // Assert the value of the SfDropDownList Assert.AreEqual(DropDownInput.Instance.Value, "Cameroon"); Assert.AreEqual(DropDownInput.Instance.Value, cut.Instance.DropVal); [Component1.Razor] <SfDropDownList TValue="string"Placeholder="e.g. Australia"TItem="Country" Width="300px" @bind-Value="@DropVal" DataSource="@Countries"> <DropDownListFieldSettings Value="Name"></DropDownListFieldSettings> </SfDropDownList> @code { public string DropVal = "Canada"; public class Country { public string Name { get; set; } public string Code { get; set; } } List<Country> Countries = new List<Country> { new Country() { Name = "Australia", Code = "AU" }, new Country() { Name = "Bermuda", Code = "BM" }, new Country() { Name = "Canada", Code = "CA" }, new Country() { Name = "Cameroon", Code = "CM" }, }; } |