Browse Source

Added WriteReadInMemory for dynamic

Piotr Czajkowski 3 months ago
parent
commit
7af8d1dcf6
1 changed files with 20 additions and 0 deletions
  1. 20 0
      ExcelORM/ExcelORMTests/DynamicWriterTests.cs

+ 20 - 0
ExcelORM/ExcelORMTests/DynamicWriterTests.cs

@@ -1,3 +1,4 @@
+using ClosedXML.Excel;
 using ExcelORM;
 
 namespace ExcelORMTests;
@@ -54,4 +55,23 @@ public class DynamicWriterTests
 
         File.Delete(testFile);
     }
+
+    [Fact]
+    public void WriteReadInMemory()
+    {
+        using var readWorkbook = new XLWorkbook(DifficultFile);
+        var reader = new ExcelDynamicReader(readWorkbook);
+        var results = reader.Read().ToArray();
+        Assert.NotEmpty(results);
+
+        using var writeWorkbook = new XLWorkbook();
+        var writer = new ExcelDynamicWriter(writeWorkbook);
+        writer.Write(results);
+
+        var savedReader = new ExcelDynamicReader(writeWorkbook);
+        var savedResults = savedReader.Read().ToArray();
+        Assert.NotEmpty(savedResults);
+        Assert.True(results.First().SequenceEqual(savedResults.First()));
+        Assert.True(results.Last().SequenceEqual(savedResults.Last()));
+    }
 }