diff --git a/src/BootstrapBlazor/Components/Toast/ToastBox.razor.cs b/src/BootstrapBlazor/Components/Toast/ToastBox.razor.cs
index 6945309ec90e25ff647247711eb9fefe9226da7a..e6be6058ecef64103cf94acd8643c3c0dc19815e 100644
--- a/src/BootstrapBlazor/Components/Toast/ToastBox.razor.cs
+++ b/src/BootstrapBlazor/Components/Toast/ToastBox.razor.cs
@@ -104,10 +104,13 @@ public partial class ToastBox : IDisposable
///
protected virtual void Dispose(bool disposing)
{
- if (disposing && Interop != null)
+ if (disposing)
{
- Interop.Dispose();
- Interop = null;
+ if (Interop != null)
+ {
+ Interop.Dispose();
+ Interop = null;
+ }
}
}
diff --git a/test/UnitTest/Components/ToastTest.cs b/test/UnitTest/Components/ToastTest.cs
index 9c19265e089cd944840ea9ee09a924f3f6fc7864..47dd0d548dbe6aeba00c2904c9310dfaf7726698 100644
--- a/test/UnitTest/Components/ToastTest.cs
+++ b/test/UnitTest/Components/ToastTest.cs
@@ -43,5 +43,82 @@ public class ToastTest : BootstrapBlazorTestBase
var service = Context.Services.GetRequiredService();
service.Success("Test", "test content");
+ service.Error("Error", "test content");
+ service.Information("Information", "test content");
+ service.Warning("Warning", "test content");
+ }
+
+ [Fact]
+ public async Task Options_Ok()
+ {
+ Context.RenderComponent();
+
+ var service = Context.Services.GetRequiredService();
+ var option = Context.Services.GetRequiredService>();
+ await service.Show(new ToastOption()
+ {
+ ForceDelay = true
+ });
+
+ await service.Success(null, "test content");
+ await service.Success("Test", null);
+ await service.Success("Test", "test content");
+
+ await service.Error(null, "test content");
+ await service.Error("Test", null);
+ await service.Error("Test", "test content");
+
+ await service.Information(null, "test content");
+ await service.Information("Test", null);
+ await service.Information("Test", "test content");
+
+ option.CurrentValue.ToastDelay = 2000;
+ await service.Warning(null, "test content");
+ await service.Warning("Test", null);
+ await service.Warning("Test", "test content");
+ }
+
+ [Fact]
+ public async Task AutoHide_Ok()
+ {
+ Context.RenderComponent();
+ var service = Context.Services.GetRequiredService();
+ await service.Show(new ToastOption()
+ {
+ IsAutoHide = false
+ });
+ }
+
+ [Fact]
+ public async Task ChildContent_Ok()
+ {
+ var cut = Context.RenderComponent();
+
+ var service = Context.Services.GetRequiredService();
+ await service.Show(new ToastOption()
+ {
+ ChildContent = new RenderFragment(builder =>
+ {
+ builder.AddContent(0, "Toast ChildContent");
+ })
+ });
+ }
+
+ [Fact]
+ public async Task Close_Ok()
+ {
+ var cut = Context.RenderComponent();
+
+ var service = Context.Services.GetRequiredService();
+ var option = new ToastOption()
+ {
+ ChildContent = new RenderFragment(builder =>
+ {
+ builder.AddContent(0, "Toast ChildContent");
+ })
+ };
+ await service.Show(option);
+
+ await option.Close();
}
}