Browse Source

Test everything

Piotr Czajkowski 5 months ago
parent
commit
8b758fab38

+ 2 - 2
ExcelORM/ExcelORM/ExcelORM.csproj

@@ -4,7 +4,7 @@
         <TargetFramework>net8.0</TargetFramework>
         <ImplicitUsings>enable</ImplicitUsings>
         <Nullable>enable</Nullable>
-        <Version>2.3.0</Version>
+        <Version>2.3.1</Version>
         <PackageProjectUrl>https://git.liox.eu/pczajkowski/ExcelORM</PackageProjectUrl>
         <RepositoryUrl>https://github.com/pczajkowski/ExcelORM</RepositoryUrl>
         <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -14,7 +14,7 @@
 	<Authors>Piotr Czajkowski</Authors>
 	<Description>Simple library to read/write C# objects from/to Excel files. </Description>
 	<RepositoryType>GitHub</RepositoryType>
-	<PackageReleaseNotes>Added Hyperlink and improved appending.</PackageReleaseNotes>
+	<PackageReleaseNotes>Write now has headerRowIndex for append.</PackageReleaseNotes>
     </PropertyGroup>
 
     <ItemGroup>

+ 3 - 4
ExcelORM/ExcelORMTests/ExcelORMTests.csproj

@@ -22,14 +22,13 @@
         </PackageReference>
     </ItemGroup>
 
-    <ItemGroup>
-      <Folder Include="testFiles\" />
-    </ItemGroup>
-
     <ItemGroup>
       <None Update="testFiles\dynamicDifficult.xlsx">
         <CopyToOutputDirectory>Always</CopyToOutputDirectory>
       </None>
+      <None Update="testFiles\forAppendHeaderFirst.xlsx">
+        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+      </None>
       <None Update="testFiles\forAppend.xlsx">
         <CopyToOutputDirectory>Always</CopyToOutputDirectory>
       </None>

+ 23 - 0
ExcelORM/ExcelORMTests/WriterTests.cs

@@ -90,6 +90,29 @@ public class WriterTests
         File.Delete(testFile);
     }
 
+    private const string ForAppendHeaderFirst = "testFiles/forAppendHeaderFirst.xlsx";
+
+    [Fact]
+    public void WriteWithAppendExistingHeaderFirst()
+    {
+        var testFile = Path.GetRandomFileName();
+        testFile = Path.ChangeExtension(testFile, "xlsx");
+        File.Copy(ForAppendHeaderFirst, testFile);
+
+        var writer = new ExcelWriter(testFile);
+        writer.Write(arrayOfThree, append: true);
+        writer.SaveAs(testFile);
+
+        var reader = new ExcelReader(testFile);
+        var readArray = reader.Read<Test>().ToArray();
+        Assert.Equal(6, readArray.Length);
+
+        for (int i = 0; i < arrayOfThree.Length; i++)
+            Assert.Equal(arrayOfThree[i], readArray[i + 3]);
+
+        File.Delete(testFile);
+    }
+
     [Fact]
     public void WriteDifferentTypes()
     {

BIN
ExcelORM/ExcelORMTests/testFiles/forAppendHeaderFirst.xlsx