From d627b7dc84e7bcfcd25938c1276fec05e8216bfc Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Thu, 15 Feb 2024 18:36:28 +0100 Subject: [PATCH] Add test --- .../Xaml.UnitTests/Issues/Maui20616.xaml | 8 +++ .../Xaml.UnitTests/Issues/Maui20616.xaml.cs | 61 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/Controls/tests/Xaml.UnitTests/Issues/Maui20616.xaml create mode 100644 src/Controls/tests/Xaml.UnitTests/Issues/Maui20616.xaml.cs diff --git a/src/Controls/tests/Xaml.UnitTests/Issues/Maui20616.xaml b/src/Controls/tests/Xaml.UnitTests/Issues/Maui20616.xaml new file mode 100644 index 000000000000..1e00b6da8e41 --- /dev/null +++ b/src/Controls/tests/Xaml.UnitTests/Issues/Maui20616.xaml @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/src/Controls/tests/Xaml.UnitTests/Issues/Maui20616.xaml.cs b/src/Controls/tests/Xaml.UnitTests/Issues/Maui20616.xaml.cs new file mode 100644 index 000000000000..77e2e3bc9da5 --- /dev/null +++ b/src/Controls/tests/Xaml.UnitTests/Issues/Maui20616.xaml.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using Microsoft.Maui.ApplicationModel; +using Microsoft.Maui.Controls.Core.UnitTests; +using Microsoft.Maui.Controls.Shapes; +using Microsoft.Maui.Devices; +using Microsoft.Maui.Dispatching; + +using Microsoft.Maui.Graphics; +using Microsoft.Maui.UnitTests; +using NUnit.Framework; + +namespace Microsoft.Maui.Controls.Xaml.UnitTests; + +public partial class Maui20616 +{ + public Maui20616() + { + InitializeComponent(); + BindingContext = new ViewModel20616 { Value = "Foo" }; + } + + public Maui20616(bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Test + { + [SetUp] + public void Setup() + { + Application.SetCurrentApplication(new MockApplication()); + DispatcherProvider.SetCurrent(new DispatcherProviderStub()); + } + + [TearDown] public void TearDown() => AppInfo.SetCurrent(null); + + [Test] + public void XDataTypeCanBeGeneric([Values(false, true)] bool useCompiledXaml) + { + if (useCompiledXaml) + { + MockCompiler.Compile(typeof(Maui20616)); + } + else + { + new Maui20616(useCompiledXaml: false); + } + } + } +} + +public class ViewModel20616 +{ + public required T Value { get; init; } +} \ No newline at end of file