ReaderWriterTests.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using ExcelORM;
  2. namespace ExcelORMTests;
  3. public class ReaderWriterTests
  4. {
  5. private const string regularFile = "testFiles/first.xlsx";
  6. private const string filteredFile = "testFiles/filtered.xlsx";
  7. class Test
  8. {
  9. [Column("First name" )]
  10. public string? Name { get; set; }
  11. [Column("Last name")]
  12. public string? Source { get; set; }
  13. [Column(new string[]{"Occupation", "Job"})]
  14. public string? Target { get; set; }
  15. }
  16. [Fact]
  17. public void Read()
  18. {
  19. var reader = new ExcelReader(regularFile);
  20. var results = reader.Read<Test>();
  21. Assert.NotNull(results);
  22. Assert.NotEmpty(results);
  23. }
  24. [Fact]
  25. public void ReadFiltered()
  26. {
  27. var reader = new ExcelReader(filteredFile);
  28. var results = reader.Read<Test>();
  29. Assert.NotNull(results);
  30. Assert.NotEmpty(results);
  31. var readerFilter = new ExcelReader(filteredFile) { ObeyFilter = true };
  32. var resultsFiltered = readerFilter.Read<Test>();
  33. Assert.NotNull(resultsFiltered);
  34. Assert.NotEmpty(resultsFiltered);
  35. }
  36. }