From b5d3bbee00feae121a4489a09aca3c12f2e221fa Mon Sep 17 00:00:00 2001 From: zhangpeihang <948869991@qq.com> Date: Wed, 23 Mar 2022 13:11:11 +0800 Subject: [PATCH 1/4] =?UTF-8?q?test:=20=E8=A1=A5=E5=85=85=20ToastService?= =?UTF-8?q?=20=E7=BB=84=E4=BB=B6=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/ToastTest.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/UnitTest/Components/ToastTest.cs b/test/UnitTest/Components/ToastTest.cs index 9c19265e0..35c58ec2f 100644 --- a/test/UnitTest/Components/ToastTest.cs +++ b/test/UnitTest/Components/ToastTest.cs @@ -43,5 +43,22 @@ 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 void Options_Ok() + { + var cut = Context.RenderComponent(); + cut.InvokeAsync(() => cut.Instance.SetPlacement(Placement.BottomStart)); + Assert.Contains("left", cut.Markup); + + var service = Context.Services.GetRequiredService(); + var option = Context.Services.GetRequiredService>(); + service.Success("Test", "test content"); + option.CurrentValue.ToastDelay = 2000; + service.Warning("Test", "test content"); } } -- Gitee From 4e4db066a67312d3e7abe785560adfad79f5492e Mon Sep 17 00:00:00 2001 From: zhangpeihang <948869991@qq.com> Date: Wed, 23 Mar 2022 20:57:32 +0800 Subject: [PATCH 2/4] =?UTF-8?q?test:=20=E8=A1=A5=E5=85=85=20Toast=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/ToastTest.cs | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/test/UnitTest/Components/ToastTest.cs b/test/UnitTest/Components/ToastTest.cs index 35c58ec2f..175abf863 100644 --- a/test/UnitTest/Components/ToastTest.cs +++ b/test/UnitTest/Components/ToastTest.cs @@ -52,8 +52,6 @@ public class ToastTest : BootstrapBlazorTestBase public void Options_Ok() { var cut = Context.RenderComponent(); - cut.InvokeAsync(() => cut.Instance.SetPlacement(Placement.BottomStart)); - Assert.Contains("left", cut.Markup); var service = Context.Services.GetRequiredService(); var option = Context.Services.GetRequiredService>(); @@ -61,4 +59,37 @@ public class ToastTest : BootstrapBlazorTestBase option.CurrentValue.ToastDelay = 2000; service.Warning("Test", "test content"); } + + [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(); + } } -- Gitee From ac570f65e7a53349b5a4c7aa4bc2c6613497c6c8 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Wed, 23 Mar 2022 22:15:15 +0800 Subject: [PATCH 3/4] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A6=86=E7=9B=96=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Toast/ToastBox.razor.cs | 9 ++++--- test/UnitTest/Components/ToastTest.cs | 26 ++++++++++++++++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/BootstrapBlazor/Components/Toast/ToastBox.razor.cs b/src/BootstrapBlazor/Components/Toast/ToastBox.razor.cs index 6945309ec..e6be6058e 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 175abf863..cae7b511c 100644 --- a/test/UnitTest/Components/ToastTest.cs +++ b/test/UnitTest/Components/ToastTest.cs @@ -49,15 +49,33 @@ public class ToastTest : BootstrapBlazorTestBase } [Fact] - public void Options_Ok() + public async Task Options_Ok() { - var cut = Context.RenderComponent(); + Context.RenderComponent(); var service = Context.Services.GetRequiredService(); var option = Context.Services.GetRequiredService>(); - service.Success("Test", "test content"); + 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; - service.Warning("Test", "test content"); + await service.Warning(null, "test content"); + await service.Warning("Test", null); + await service.Warning("Test", "test content"); } [Fact] -- Gitee From cab4b90463648f60c3b97a01e7e7b13622b75088 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Wed, 23 Mar 2022 22:20:23 +0800 Subject: [PATCH 4/4] =?UTF-8?q?test:=20add=20=20IsAutoHide=20=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/ToastTest.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/UnitTest/Components/ToastTest.cs b/test/UnitTest/Components/ToastTest.cs index cae7b511c..47dd0d548 100644 --- a/test/UnitTest/Components/ToastTest.cs +++ b/test/UnitTest/Components/ToastTest.cs @@ -78,6 +78,17 @@ public class ToastTest : BootstrapBlazorTestBase 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() { -- Gitee