BindingTests_Source.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 Moq;
  4. using Avalonia.Controls;
  5. using Avalonia.Data;
  6. using Avalonia.Markup.Data;
  7. using Avalonia.Markup.Xaml.Data;
  8. using ReactiveUI;
  9. using Xunit;
  10. namespace Avalonia.Markup.Xaml.UnitTests.Data
  11. {
  12. public class BindingTests_Source
  13. {
  14. [Fact]
  15. public void Source_Should_Be_Used()
  16. {
  17. var source = new Source { Foo = "foo" };
  18. var binding = new Binding { Source = source, Path = "Foo" };
  19. var target = new TextBlock();
  20. target.Bind(TextBlock.TextProperty, binding);
  21. Assert.Equal(target.Text, "foo");
  22. }
  23. public class Source : ReactiveObject
  24. {
  25. private string _foo;
  26. public string Foo
  27. {
  28. get { return _foo; }
  29. set { this.RaiseAndSetIfChanged(ref _foo, value); }
  30. }
  31. }
  32. }
  33. }