SelectorTests_PropertyEquals.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System.Linq;
  4. using System.Reactive.Linq;
  5. using System.Threading.Tasks;
  6. using Avalonia.Controls;
  7. using Xunit;
  8. namespace Avalonia.Styling.UnitTests
  9. {
  10. public class SelectorTests_PropertyEquals
  11. {
  12. [Fact]
  13. public async Task PropertyEquals_Matches_When_Property_Has_Matching_Value()
  14. {
  15. var control = new TextBlock();
  16. var target = default(Selector).PropertyEquals(TextBlock.TextProperty, "foo");
  17. var activator = target.Match(control).ObservableResult;
  18. Assert.False(await activator.Take(1));
  19. control.Text = "foo";
  20. Assert.True(await activator.Take(1));
  21. control.Text = null;
  22. Assert.False(await activator.Take(1));
  23. }
  24. [Fact]
  25. public void PropertyEquals_Selector_Should_Have_Correct_String_Representation()
  26. {
  27. var target = default(Selector)
  28. .OfType<TextBlock>()
  29. .PropertyEquals(TextBlock.TextProperty, "foo");
  30. Assert.Equal("TextBlock[Text=foo]", target.ToString());
  31. }
  32. }
  33. }