浏览代码

Added ToObject_EnumAsString

Piotr Czajkowski 1 周之前
父节点
当前提交
021af2943b
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      ExcelORM/ExcelORMTests/TypeExtensionsTests.cs

+ 13 - 0
ExcelORM/ExcelORMTests/TypeExtensionsTests.cs

@@ -41,4 +41,17 @@ public class TypeExtensionsTests
         Assert.IsType<Guid>(readValue);
         Assert.NotEqual(Guid.Empty, readValue);
     }
+     
+    public TestEnum? EnumProperty { get; set; }
+    
+    [Fact]
+    public void ToObject_EnumAsString()
+    {
+        XLCellValue value = "Second";
+        
+        var propertyInfo = typeof(TypeExtensionsTests).GetProperty("EnumProperty");
+        var readValue = value.ToObject(propertyInfo);
+        Assert.IsType<TestEnum>(readValue);
+        Assert.NotEqual(TestEnum.First, readValue);
+    }
 }