Browse Source

Added another failing test.

Steven Kirk 3 years ago
parent
commit
b650bb65b2
1 changed files with 34 additions and 0 deletions
  1. 34 0
      tests/Avalonia.Base.UnitTests/Styling/StyleTests.cs

+ 34 - 0
tests/Avalonia.Base.UnitTests/Styling/StyleTests.cs

@@ -260,6 +260,40 @@ namespace Avalonia.Base.UnitTests.Styling
             Assert.Equal(123.4, target.Double);
         }
 
+        [Fact]
+        public void Later_Styles_Should_Override_Earlier_With_Begin_End_Styling()
+        {
+            Styles styles = new Styles
+            {
+                new Style(x => x.OfType<Class1>().Class("foo"))
+                {
+                    Setters =
+                    {
+                        new Setter(Class1.FooProperty, "foo1"),
+                        new Setter(Class1.DoubleProperty, 123.4),
+                    },
+                },
+
+                new Style(x => x.OfType<Class1>().Class("foo").Class("bar"))
+                {
+                    Setters =
+                    {
+                        new Setter(Class1.FooProperty, "foo2"),
+                    },
+                },
+            };
+
+            var target = new Class1();
+            target.GetValueStore().BeginStyling();
+            styles.TryAttach(target, null);
+            target.GetValueStore().EndStyling();
+            target.Classes.Add("bar");
+            target.Classes.Add("foo");
+
+            Assert.Equal("foo2", target.Foo);
+            Assert.Equal(123.4, target.Double);
+        }
+
         [Fact]
         public void Inactive_Values_Should_Not_Be_Made_Active_During_Style_Attach()
         {