Skip to content

Commit e675ab7

Browse files
committed
test: 增加单元测试
1 parent 7dd8a34 commit e675ab7

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

src/BootstrapBlazor/Options/MarginOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace BootstrapBlazor.Components;
88
/// <summary>
99
/// 页面边距选项
1010
/// </summary>
11+
[ExcludeFromCodeCoverage]
1112
public record MarginOptions
1213
{
1314
/// <summary>

src/BootstrapBlazor/Options/PaperFormat.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace BootstrapBlazor.Components;
88
/// <summary>
99
/// 纸张规格配置类
1010
/// </summary>
11+
[ExcludeFromCodeCoverage]
1112
public record PaperFormat
1213
{
1314
/// <summary>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace UnitTest.Options;
7+
8+
public class PdfOptionsTest
9+
{
10+
[Fact]
11+
public void Test_PdfOptions_Ok()
12+
{
13+
var options = new PdfOptions()
14+
{
15+
Scale = 1.0m,
16+
DisplayHeaderFooter = true,
17+
PrintBackground = true,
18+
Landscape = true,
19+
Format = PaperFormat.A1,
20+
MarginOptions = new MarginOptions()
21+
{
22+
Top = "10mm",
23+
Bottom = "10mm",
24+
Left = "10mm",
25+
Right = "10mm"
26+
}
27+
};
28+
Assert.Equal(1.0m, options.Scale);
29+
Assert.True(options.DisplayHeaderFooter);
30+
Assert.True(options.PrintBackground);
31+
Assert.True(options.Landscape);
32+
Assert.Equal(PaperFormat.A1, options.Format);
33+
Assert.Equal("10mm", options.MarginOptions.Top);
34+
Assert.Equal("10mm", options.MarginOptions.Bottom);
35+
Assert.Equal("10mm", options.MarginOptions.Left);
36+
Assert.Equal("10mm", options.MarginOptions.Right);
37+
}
38+
}

0 commit comments

Comments
 (0)