From b650bb65b240862fc6a4ec141b5414693535e5cc Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 29 Sep 2022 20:22:34 +0200 Subject: [PATCH] Added another failing test. --- .../Styling/StyleTests.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/Avalonia.Base.UnitTests/Styling/StyleTests.cs b/tests/Avalonia.Base.UnitTests/Styling/StyleTests.cs index 5f13beb8f8..49caa5aa65 100644 --- a/tests/Avalonia.Base.UnitTests/Styling/StyleTests.cs +++ b/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().Class("foo")) + { + Setters = + { + new Setter(Class1.FooProperty, "foo1"), + new Setter(Class1.DoubleProperty, 123.4), + }, + }, + + new Style(x => x.OfType().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() {