ExpressionObserverBuilderTests_Property.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Avalonia.Data;
  2. using Avalonia.Markup.Parsers;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Reactive.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Xunit;
  9. namespace Avalonia.Markup.UnitTests.Parsers
  10. {
  11. public class ExpressionObserverBuilderTests_Property
  12. {
  13. [Fact]
  14. public async Task Should_Return_BindingNotification_Error_For_Broken_Chain()
  15. {
  16. var data = new { Foo = new { Bar = 1 } };
  17. var target = ExpressionObserverBuilder.Build(data, "Foo.Bar.Baz");
  18. var result = await target.Take(1);
  19. Assert.IsType<BindingNotification>(result);
  20. Assert.Equal(
  21. new BindingNotification(
  22. new MissingMemberException("Could not find CLR property 'Baz' on '1'"), BindingErrorType.Error),
  23. result);
  24. GC.KeepAlive(data);
  25. }
  26. [Fact]
  27. public void Should_Have_Null_ResultType_For_Broken_Chain()
  28. {
  29. var data = new { Foo = new { Bar = 1 } };
  30. var target = ExpressionObserverBuilder.Build(data, "Foo.Bar.Baz");
  31. Assert.Null(target.ResultType);
  32. GC.KeepAlive(data);
  33. }
  34. }
  35. }