diff options
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml | 3 | ||||
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs | 38 |
2 files changed, 38 insertions, 3 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml index 62c1abd2..3e0f7f5b 100644 --- a/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml +++ b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?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" @@ -16,6 +16,7 @@ <ResourceDictionary MergedWith="local:SharedResourceDictionary2"/> </ContentView.Resources> <Label x:Name="label2" Style="{StaticResource sharedStyle2}"/> + <Label x:Name="label3" Text="{StaticResource foo}"/> </ContentView> </StackLayout> </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 index a272decc..b9329e4a 100644 --- a/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs +++ b/Xamarin.Forms.Xaml.UnitTests/TestSharedResourceDictionary.xaml.cs @@ -1,6 +1,5 @@ using NUnit.Framework; - -using Xamarin.Forms; +using Xamarin.Forms.Core.UnitTests; namespace Xamarin.Forms.Xaml.UnitTests { @@ -19,6 +18,23 @@ namespace Xamarin.Forms.Xaml.UnitTests [TestFixture] public class Tests { + [SetUp] + public void Setup() + { + Device.PlatformServices = new MockPlatformServices(); + Application.Current = new MockApplication { + Resources = new ResourceDictionary { + MergedWith = typeof(MyRD) + } + }; + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; + } + [TestCase (false)] [TestCase (true)] public void MergedResourcesAreFound (bool useCompiledXaml) @@ -43,6 +59,24 @@ namespace Xamarin.Forms.Xaml.UnitTests var layout = new TestSharedResourceDictionary(useCompiledXaml); Assert.AreEqual(Color.Red, layout.implicitLabel.TextColor); } + + class MyRD : ResourceDictionary + { + public MyRD() + { + Add("foo", "Foo"); + Add("bar", "Bar"); + } + } + + [TestCase(false)] + [TestCase(true)] + public void MergedRDAtAppLevel(bool useCompiledXaml) + { + var layout = new TestSharedResourceDictionary(useCompiledXaml); + Assert.AreEqual("Foo", layout.label3.Text); + } + } } }
\ No newline at end of file |