Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrozsival committed Feb 15, 2024
1 parent 29ab91b commit d627b7d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Maui20616.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests"
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui20616">
<Label Text="{Binding Value}" x:DataType="local:ViewModel20616(x:String)" />
<Label Text="{Binding Value}" x:DataType="{x:Type local:ViewModel20616(x:String)}" />
</ContentPage>
61 changes: 61 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Maui20616.xaml.cs
Original file line number Diff line number Diff line change
@@ -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<string> { 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<T>
{
public required T Value { get; init; }
}

0 comments on commit d627b7d

Please sign in to comment.