From b21d5d0dfbb2026a4ac632045f2d4b40b0844358 Mon Sep 17 00:00:00 2001 From: zhangpeihang <948869991@qq.com> Date: Tue, 22 Mar 2022 18:07:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?test:=20=E6=B7=BB=E5=8A=A0=20handwirtten=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/HandwrittenTest.cs | 51 +++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/UnitTest/Components/HandwrittenTest.cs diff --git a/test/UnitTest/Components/HandwrittenTest.cs b/test/UnitTest/Components/HandwrittenTest.cs new file mode 100644 index 000000000..5f0e117a3 --- /dev/null +++ b/test/UnitTest/Components/HandwrittenTest.cs @@ -0,0 +1,51 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Website: https://www.blazor.zone or https://argozhang.github.io/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UnitTest.Components; + +public class HandwrittenTest : BootstrapBlazorTestBase +{ + [Fact] + public void ClearButtonText_OK() + { + var cut = Context.RenderComponent(builder => builder.Add(s => s.ClearButtonText, "Clear Text")); + + Assert.Contains("Clear Text", cut.Markup); + } + + [Fact] + public void SaveButtonText_OK() + { + var cut = Context.RenderComponent(builder => builder.Add(s => s.SaveButtonText, "Save Text")); + + Assert.Contains("Save Text", cut.Markup); + } + + [Fact] + public async Task HandwrittenBase64_OK() + { + var ret = false; + var cut = Context.RenderComponent(builder => + { + builder.Add(s => s.HandwrittenBase64, EventCallback.Factory.Create(this, v => + { + ret = true; + })); + }); + + await cut.InvokeAsync(async () => + { + await cut.Instance.OnValueChanged("test"); + var result = cut.Instance.Result; + Assert.True(ret); + Assert.Equal("test", result); + }); + } +} -- Gitee From 5654ddd2a82739da153f5e9a3f75bca3977692b8 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Tue, 22 Mar 2022 22:29:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Handwritten/Handwritten.razor.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Components/Handwritten/Handwritten.razor.cs b/src/BootstrapBlazor/Components/Handwritten/Handwritten.razor.cs index aa80440b1..f64412faf 100644 --- a/src/BootstrapBlazor/Components/Handwritten/Handwritten.razor.cs +++ b/src/BootstrapBlazor/Components/Handwritten/Handwritten.razor.cs @@ -95,8 +95,11 @@ public partial class Handwritten : IDisposable { if (disposing) { - Interop?.Dispose(); - Interop = null; + if (Interop != null) + { + Interop?.Dispose(); + Interop = null; + } } } -- Gitee