Skip to content

IMatDialogService + BUnit #919

@drma-tech

Description

@drma-tech

I don't know if you guys use BUnit, component to test Blazor.

I'm trying to initialize the IMatDialogService, but I can't manually initialize this service.
ctx.RegisterDialogService(typeof(ChangeDialog), new());

public static void RegisterDialogService(this TestContext ctx, Type componentType, Dictionary<string, object> attributes)
{
    var services = new MatPortalService();
    services.Add(componentType, attributes);
    ctx.Services.AddSingleton<IMatDialogService>(new MatDialogService(services));
}
var cut = ctx.RenderComponent<ChangeDialog>(parameters => parameters
    .Add(p => p.DialogReference, new MatDialogReference() { Service = new MatDialogService(new MatPortalService()) })
);
var att = new Dictionary<string, object>
{
    { "VariableName", "xyz" },
    { "VariableValue", "xyz" },
    { "VariableType", VariableType.SingleLine }
};

await cut.Instance.DialogReference.Service.OpenAsync(typeof(ChangeDialog), new MatDialogOptions() { Attributes = att });

when I run that last line of code, the system crashes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions