From fd3e561404ee295345ac5bf99930b10faca6082f Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 19 Jul 2022 15:46:58 +0200 Subject: [PATCH] Reinstated test. --- .../Styling/StyleTests.cs | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/tests/Avalonia.Base.UnitTests/Styling/StyleTests.cs b/tests/Avalonia.Base.UnitTests/Styling/StyleTests.cs index d1d4120c9b..a8dbfc7142 100644 --- a/tests/Avalonia.Base.UnitTests/Styling/StyleTests.cs +++ b/tests/Avalonia.Base.UnitTests/Styling/StyleTests.cs @@ -464,40 +464,39 @@ namespace Avalonia.Base.UnitTests.Styling [Fact] public void Template_In_Inactive_Style_Is_Not_Built() { - throw new NotImplementedException(); - ////var instantiationCount = 0; - ////var template = new FuncTemplate(() => - ////{ - //// ++instantiationCount; - //// return new Class1(); - ////}); - - ////Styles styles = new Styles - ////{ - //// new Style(x => x.OfType()) - //// { - //// Setters = - //// { - //// new Setter(Class1.ChildProperty, template), - //// }, - //// }, - - //// new Style(x => x.OfType()) - //// { - //// Setters = - //// { - //// new Setter(Class1.ChildProperty, template), - //// }, - //// } - ////}; - - ////var target = new Class1(); - ////target.BeginBatchUpdate(); - ////styles.TryAttach(target, null); - ////target.EndBatchUpdate(); - - ////Assert.NotNull(target.Child); - ////Assert.Equal(1, instantiationCount); + var instantiationCount = 0; + var template = new FuncTemplate(() => + { + ++instantiationCount; + return new Class1(); + }); + + Styles styles = new Styles + { + new Style(x => x.OfType()) + { + Setters = + { + new Setter(Class1.ChildProperty, template), + }, + }, + + new Style(x => x.OfType()) + { + Setters = + { + new Setter(Class1.ChildProperty, template), + }, + } + }; + + var target = new Class1(); + target.GetValueStore().BeginStyling(); + styles.TryAttach(target, null); + target.GetValueStore().EndStyling(); + + Assert.NotNull(target.Child); + Assert.Equal(1, instantiationCount); } [Fact]