TypeExtensionsTests.cs 827 B

12345678910111213141516171819202122232425262728293031
  1. using ClosedXML.Excel;
  2. using ExcelORM;
  3. namespace ExcelORMTests;
  4. public class TypeExtensionsTests
  5. {
  6. public DateTime? DateTimeProperty { get; set; }
  7. [Fact]
  8. public void ToObject_DateTimeAsString()
  9. {
  10. XLCellValue value = "7/27/2025";
  11. var propertyInfo = typeof(TypeExtensionsTests).GetProperty("DateTimeProperty");
  12. var readValue = value.ToObject(propertyInfo);
  13. Assert.IsType<DateTime>(readValue);
  14. }
  15. public DateOnly? DateOnlyProperty { get; set; }
  16. [Fact]
  17. public void ToObject_DateOnlyAsString()
  18. {
  19. XLCellValue value = "7/27/2025";
  20. var propertyInfo = typeof(TypeExtensionsTests).GetProperty("DateOnlyProperty");
  21. var readValue = value.ToObject(propertyInfo);
  22. Assert.IsType<DateOnly>(readValue);
  23. }
  24. }