Пример #1
0
        public async Task DisposeTest()
        {
            var comp = ctx.RenderComponent <MudSnackbarProvider>();

            Console.WriteLine(comp.Markup);
            comp.Find("#mud-snackbar-container").InnerHtml.Trim().Should().BeEmpty();
            var service = ctx.Services.GetService <ISnackbar>() as SnackbarService;

            service.Should().NotBe(null);

            // shoot out a snackbar
            Snackbar snackbar = null;
            await comp.InvokeAsync(() => snackbar = service?.Add("Boom, big reveal. Im a pickle!"));

            Console.WriteLine(comp.Markup);

            snackbar?.Dispose();

            comp.Find("#mud-snackbar-container").InnerHtml.Trim().Should().NotBeEmpty();
            comp.Find("div.mud-snackbar-content-message").TrimmedText().Should().Be("Boom, big reveal. Im a pickle!");
            // close by click on the snackbar
            comp.Find("button").Click();
            comp.WaitForAssertion(() => comp.Find("#mud-snackbar-container").InnerHtml.Trim().Should().BeEmpty(), TimeSpan.FromMilliseconds(100));
        }