Browse Source

!B Fixing test

Luis von der Eltz 5 years ago
parent
commit
d88640b1ea

+ 11 - 1
tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/BindingExtensionTests.cs

@@ -47,19 +47,29 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions
                 var xaml = @"
 <Window xmlns='https://github.com/avaloniaui'
              xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
-    <TextBlock Name='textBlock' Text='{Binding Source={x:Null}, TargetNullValue='foobar'}'/>
+    <Window.Resources>
+        <x:String x:Key='text'>foobar</x:String>
+    </Window.Resources>
+
+    <TextBlock Name='textBlock' Text='{Binding Foo, TargetNullValue={StaticResource text}}'/>
 </Window>";
 
                 var loader = new AvaloniaXamlLoader();
                 var window = (Window)loader.Load(xaml);
                 var textBlock = window.FindControl<TextBlock>("textBlock");
 
+                window.DataContext = new FooBar();
                 window.Show();
 
                 Assert.Equal("foobar", textBlock.Text);
             }
         }
 
+        private class FooBar
+        {
+            public object Foo { get; } = null;
+        }
+
         private IDisposable StyledWindow(params (string, string)[] assets)
         {
             var services = TestServices.StyledWindow.With(