summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-04-27 11:17:27 +0200
committerStephane Delcroix <stephane@delcroix.org>2017-04-27 11:18:43 +0200
commitdc3c410c5df3b62d9eb312e60ea25b1de61fe2c5 (patch)
tree4db97aa4eaec29d8196c5cd7a82c31a9dba5f4b9 /Xamarin.Forms.Xaml.UnitTests
parent25f485b3d53da860ec6aa18c5fd1fad4bff290dc (diff)
downloadxamarin-forms-dc3c410c5df3b62d9eb312e60ea25b1de61fe2c5.tar.gz
xamarin-forms-dc3c410c5df3b62d9eb312e60ea25b1de61fe2c5.tar.bz2
xamarin-forms-dc3c410c5df3b62d9eb312e60ea25b1de61fe2c5.zip
[XamlC] support valueTypes x:Arrays (#875)
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz54717.xaml15
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz54717.xaml.cs53
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj8
3 files changed, 75 insertions, 1 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz54717.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz54717.xaml
new file mode 100644
index 00000000..1185d225
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz54717.xaml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.Bz54717">
+ <ContentPage.Resources>
+ <ResourceDictionary>
+ <x:Array x:Key="SomeColors" Type="{x:Type Color}">
+ <x:StaticResource Key="Color1" />
+ <x:StaticResource Key="Color2" />
+ </x:Array>
+ </ResourceDictionary>
+ </ContentPage.Resources>
+ <StackLayout>
+ </StackLayout>
+</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz54717.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz54717.xaml.cs
new file mode 100644
index 00000000..c959859b
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz54717.xaml.cs
@@ -0,0 +1,53 @@
+using System;
+using NUnit.Framework;
+using Xamarin.Forms.Core.UnitTests;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public partial class Bz54717 : ContentPage
+ {
+ public Bz54717()
+ {
+ InitializeComponent();
+ }
+
+ public Bz54717(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ class Tests
+ {
+ [SetUp]
+ public void Setup()
+ {
+ Device.PlatformServices = new MockPlatformServices();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Device.PlatformServices = null;
+ Application.Current = null;
+ }
+
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Foo(bool useCompiledXaml)
+ {
+ Application.Current = new MockApplication {
+ Resources = new ResourceDictionary {
+ {"Color1", Color.Red},
+ {"Color2", Color.Blue},
+ }
+ };
+ var layout = new Bz54717(useCompiledXaml);
+ Assert.That(layout.Resources.Count, Is.EqualTo(1));
+ var array = layout.Resources["SomeColors"] as Color[];
+ Assert.That(array[0], Is.EqualTo(Color.Red));
+ Assert.That(array[1], Is.EqualTo(Color.Blue));
+ }
+ }
+ }
+}
diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
index 05ff0e15..123a0d59 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -476,9 +476,12 @@
<Compile Include="Issues\Bz55343.xaml.cs">
<DependentUpon>Bz55343.xaml</DependentUpon>
</Compile>
+ <Compile Include="Issues\Bz54717.xaml.cs">
+ <DependentUpon>Bz54717.xaml</DependentUpon>
+ </Compile>
<Compile Include="Issues\Bz55347.xaml.cs">
<DependentUpon>Bz55347.xaml</DependentUpon>
- </Compile>
+ </Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
@@ -875,6 +878,9 @@
<EmbeddedResource Include="Issues\Bz55343.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="Issues\Bz54717.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
<EmbeddedResource Include="Issues\Bz55347.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>