Prechádzať zdrojové kódy

Prettier and more testing

Piotr Czajkowski 1 rok pred
rodič
commit
af4ae1e3ad

+ 1 - 5
ExcelORM/ExcelORM/ExcelReader.cs

@@ -45,11 +45,7 @@ public class ExcelReader
 
     public IEnumerable<T> Read<T>() where T : class, new()
     {
-        foreach (var worksheet in xlWorkbook.Worksheets)
-        {
-            foreach (var value in Read<T>(worksheet))
-                yield return value;
-        }
+        return xlWorkbook.Worksheets.SelectMany(Read<T>);
     }
 
     public IEnumerable<T> Read<T>(string? worksheetName) where T : class, new()

+ 2 - 2
ExcelORM/ExcelORMTests/WriterTests.cs

@@ -29,13 +29,13 @@ public class WriterTests
         writer.SaveAs(testFile);
 
         var reader = new ExcelReader(testFile);
-        Assert.Equal(3, reader.Read<Test>().Count());
+        Assert.Equal(3, reader.Read<Test>(worksheetName).Count());
 
         writer.Write(listOfTwo, worksheetName, true);
         writer.SaveAs(testFile);
         
         reader = new ExcelReader(testFile);
-        Assert.Equal(5, reader.Read<Test>().Count());
+        Assert.Equal(5, reader.Read<Test>(worksheetName).Count());
         File.Delete(testFile);
     }