-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
max
committed
Jan 15, 2024
1 parent
063a72f
commit 8ac5f59
Showing
6 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
Excely.ClosedXML.UnitTests/Excely.ClosedXML.UnitTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="ClosedXML" Version="0.102.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" /> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Excely.ClosedXML\Excely.ClosedXML.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Microsoft.VisualStudio.TestTools.UnitTesting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Excely.ClosedXML.UnitTests.Models | ||
{ | ||
internal enum SampleEnum | ||
{ | ||
Enum1, | ||
Enum2, | ||
Enum3, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Excely.ClosedXML.UnitTests.Models | ||
{ | ||
internal class SimpleClass | ||
{ | ||
public int IntValue { get; set; } | ||
public string StrigValue { get; set; } = ""; | ||
public DateTime DateTimeValue { get; set; } | ||
public SampleEnum EnumValue { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using ClosedXML.Excel; | ||
using Excely.ClosedXML.TableConverters; | ||
|
||
namespace Excely.ClosedXML.UnitTests | ||
{ | ||
[TestClass] | ||
public class XlsxTableConverterTests | ||
{ | ||
/// <summary> | ||
/// 確保 ClosedXML 在處理字串時不會自動轉型為數字 | ||
/// </summary> | ||
[TestMethod] | ||
public void ConvertPaddingStartWith0Data_ShouldReturnExcelWithCurrectData() | ||
{ | ||
// Arrange | ||
using var workbook = new XLWorkbook(); | ||
var worksheet = workbook.AddWorksheet("sheet1"); | ||
|
||
var converter = new XlsxTableConverter(worksheet); | ||
var table = new ExcelyTable(new List<IList<object?>> | ||
{ | ||
new List<object?> { "Name", "No" }, | ||
new List<object?> { "John", "01" }, | ||
}); | ||
|
||
// Act | ||
converter.ConvertFrom(table); | ||
|
||
// Assert | ||
Assert.AreEqual("01", worksheet.Cell(2,2).Value.ToString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters