summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml14
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml.cs34
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml11
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs31
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj12
5 files changed, 102 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml b/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml
new file mode 100644
index 00000000..8d86d57a
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.SharedResourceDictionary">
+ <Style x:Key="sharedfoo" TargetType="Label">
+ <Setter Property="TextColor" Value="Pink" />
+ </Style>
+ <Style x:Key="sharedbar" TargetType="Label">
+ <Setter Property="TextColor" Value="Blue" />
+ </Style>
+ <Style TargetType="Label">
+ <Setter Property="TextColor" Value="Red" />
+ </Style>
+</ResourceDictionary> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml.cs
new file mode 100644
index 00000000..f4f53cae
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/SharedResourceDictionary.xaml.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+
+using Xamarin.Forms;
+
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public partial class SharedResourceDictionary : ResourceDictionary
+ {
+ public SharedResourceDictionary ()
+ {
+ InitializeComponent ();
+ }
+
+ public SharedResourceDictionary (bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ public class Tests
+ {
+ [TestCase (false)]
+ [TestCase (true)]
+ public void ResourcesDirectoriesCanBeXamlRoots (bool useCompiledXaml)
+ {
+ var layout = new SharedResourceDictionary (useCompiledXaml);
+ Assert.AreEqual (3, layout.Count);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml
new file mode 100644
index 00000000..eb1eb7e4
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ xmlns:local="clr-namespace:Xamarin.Forms.Xaml.UnitTests"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.TestSharedResourceDictionary">
+ <ContentPage.Resources>
+ <ResourceDictionary MergedWith="local:SharedResourceDictionary">
+ </ResourceDictionary>
+ </ContentPage.Resources>
+ <Label x:Name="label" Style="{StaticResource sharedfoo}"/>
+</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs
new file mode 100644
index 00000000..dff3f893
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs
@@ -0,0 +1,31 @@
+using NUnit.Framework;
+
+using Xamarin.Forms;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public partial class TestSharedResourceDictionary : ContentPage
+ {
+ public TestSharedResourceDictionary ()
+ {
+ InitializeComponent ();
+ }
+
+ public TestSharedResourceDictionary (bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ public class Tests
+ {
+ [TestCase (false)]
+ [TestCase (true)]
+ public void MergedResourcesAreFound (bool useCompiledXaml)
+ {
+ var layout = new TestSharedResourceDictionary (useCompiledXaml);
+ Assert.AreEqual (Color.Pink, layout.label.TextColor);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
index 961774f0..54433f56 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -335,6 +335,12 @@
<DependentUpon>McIgnorable.xaml</DependentUpon>
</Compile>
<Compile Include="XamlLoaderCreateTests.cs" />
+ <Compile Include="SharedResourceDictionary.xaml.cs">
+ <DependentUpon>SharedResourceDictionary.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="TestSharedResourceDictionary.xaml.cs">
+ <DependentUpon>TestSharedResourceDictionary.xaml</DependentUpon>
+ </Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
@@ -596,6 +602,12 @@
<EmbeddedResource Include="McIgnorable.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="SharedResourceDictionary.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
+ <EmbeddedResource Include="TestSharedResourceDictionary.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />