TypeExtensionsTests.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. public Guid? GuidProperty { get; set; }
  25. [Fact]
  26. public void ToObject_GuidAsString()
  27. {
  28. XLCellValue value = "00000000-0000-0000-0000-000000000001";
  29. var propertyInfo = typeof(TypeExtensionsTests).GetProperty("GuidProperty");
  30. var readValue = value.ToObject(propertyInfo);
  31. Assert.IsType<Guid>(readValue);
  32. Assert.NotEqual(Guid.Empty, readValue);
  33. }
  34. }