From cf866e2292fa1745f098ffe195679be865711874 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Sun, 19 Dec 2021 17:13:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20LinkButton=20?= =?UTF-8?q?=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/LinkButtonTest.cs | 70 ++++++++++++++++++++++ test/UnitTest/Utils/UtilityTest.cs | 2 - 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 test/UnitTest/Components/LinkButtonTest.cs diff --git a/test/UnitTest/Components/LinkButtonTest.cs b/test/UnitTest/Components/LinkButtonTest.cs new file mode 100644 index 000000000..093a938c9 --- /dev/null +++ b/test/UnitTest/Components/LinkButtonTest.cs @@ -0,0 +1,70 @@ +// 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 BootstrapBlazor.Components; +using Bunit; +using Microsoft.AspNetCore.Components; +using UnitTest.Core; +using Xunit; + +namespace UnitTest.Components +{ + public class LinkButtonTest : BootstrapBlazorTestBase + { + [Fact] + public void Text_Ok() + { + var cut = Context.RenderComponent(builder => builder.Add(s => s.Text, "TestButton")); + + Assert.Contains("TestButton", cut.Markup); + } + + [Fact] + public void Url_Ok() + { + var cut = Context.RenderComponent(builder => builder.Add(s => s.Url, "https://www.blazor.zone")); + + Assert.Contains("https://www.blazor.zone", cut.Markup); + } + + [Fact] + public void ImageUrl_Ok() + { + var cut = Context.RenderComponent(builder => builder.Add(s => s.ImageUrl, "Argo-C.png")); + + Assert.Contains("Argo-C.png", cut.Markup); + } + + [Fact] + public void Title_Ok() + { + var cut = Context.RenderComponent(builder => + { + builder.Add(s => s.Title, "Tooltip"); + builder.Add(s => s.TooltipPlacement, Placement.Bottom); + }); + } + + [Fact] + public void ChildContent_Ok() + { + var cut = Context.RenderComponent(builder => builder.Add(s => s.ChildContent, b => + { + b.AddContent(0, new MarkupString("
Test
")); + })); + + Assert.Contains("
Test
", cut.Markup); + } + + [Fact] + public void OnClick_Ok() + { + var click = false; + var cut = Context.RenderComponent(builder => builder.Add(s => s.OnClick, () => click = true)); + + cut.Find("a").Click(); + Assert.True(click); + } + } +} diff --git a/test/UnitTest/Utils/UtilityTest.cs b/test/UnitTest/Utils/UtilityTest.cs index 3bedc47ae..a23515fe3 100644 --- a/test/UnitTest/Utils/UtilityTest.cs +++ b/test/UnitTest/Utils/UtilityTest.cs @@ -91,8 +91,6 @@ namespace UnitTest.Utils private class Dummy { public string? Name { get; set; } - - public string? Id; } private class MockClone : ICloneable -- Gitee From 0743fbbb1d63814a8dc5c0c4ec01bee415c0da0d Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Sun, 19 Dec 2021 17:14:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=E7=A7=BB=E9=99=A4=20Task=20?= =?UTF-8?q?=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/Utils/ConverterTest.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/UnitTest/Utils/ConverterTest.cs b/test/UnitTest/Utils/ConverterTest.cs index f1d1dc4ec..7c65a4205 100644 --- a/test/UnitTest/Utils/ConverterTest.cs +++ b/test/UnitTest/Utils/ConverterTest.cs @@ -6,30 +6,12 @@ using BootstrapBlazor.Components; using Microsoft.AspNetCore.Components; using System; using System.Globalization; -using System.Threading; -using System.Threading.Tasks; using Xunit; namespace UnitTest.Utils { public class ConverterTest { - [Fact] - public async Task Task_Test() - { - var error = false; - CancellationTokenSource cts = new(10); - try - { - await Task.Delay(50, cts.Token); - } - catch (TaskCanceledException) - { - error = true; - } - Assert.True(error); - } - [Fact] public void NullableBool_Test() { -- Gitee