diff --git a/test/UnitTest/Components/LinkButtonTest.cs b/test/UnitTest/Components/LinkButtonTest.cs new file mode 100644 index 0000000000000000000000000000000000000000..093a938c9f5b6c68d5decb000a97f61071defb1f --- /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/ConverterTest.cs b/test/UnitTest/Utils/ConverterTest.cs index f1d1dc4eca16b7eadc40fff91a1b89dbf9590cc8..7c65a4205abde33df0bc60e42ab9ad25e8dfb575 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() { diff --git a/test/UnitTest/Utils/UtilityTest.cs b/test/UnitTest/Utils/UtilityTest.cs index 3bedc47aeca4708624f825bfdac52366e2bbd6b3..a23515fe328aa2e9813cde98af7e8d0880eebfab 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