ReflectionClrPropertyInfoTests.cs 617 B

123456789101112131415161718192021222324
  1. using Avalonia.Data.Core;
  2. using Xunit;
  3. namespace Avalonia.Base.UnitTests.Data;
  4. public class ReflectionClrPropertyInfoTests
  5. {
  6. public class TestClass
  7. {
  8. public string Test { get; set; }
  9. }
  10. [Fact]
  11. public void Can_Compile()
  12. {
  13. var propertyInfo = new ReflectionClrPropertyInfo(
  14. typeof(TestClass).GetProperty(nameof(TestClass.Test))!);
  15. var target = new TestClass();
  16. const string result = "qwerty";
  17. propertyInfo.Set(target, result);
  18. Assert.Equal(result, target.Test);
  19. Assert.Equal(result, (string)propertyInfo.Get(target));
  20. }
  21. }