diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2017-06-14 09:33:36 +0200 |
---|---|---|
committer | Stephane Delcroix <stephane@delcroix.org> | 2017-06-14 09:33:36 +0200 |
commit | 28a878d14fa9f763bd76cb8e33ddcb539795316f (patch) | |
tree | 519f5dbe2328b88eb6b803a2ed95349317dd3cdc | |
parent | 88693cc316df3ffaeca4871362d2639504258989 (diff) | |
download | xamarin-forms-28a878d14fa9f763bd76cb8e33ddcb539795316f.tar.gz xamarin-forms-28a878d14fa9f763bd76cb8e33ddcb539795316f.tar.bz2 xamarin-forms-28a878d14fa9f763bd76cb8e33ddcb539795316f.zip |
[test] add passing test for 56852
4 files changed, 72 insertions, 3 deletions
diff --git a/Xamarin.Forms.Core/BindableObject.cs b/Xamarin.Forms.Core/BindableObject.cs index 35e3648f..d45580f8 100644 --- a/Xamarin.Forms.Core/BindableObject.cs +++ b/Xamarin.Forms.Core/BindableObject.cs @@ -298,9 +298,9 @@ namespace Xamarin.Forms internal void SetDynamicResource(BindableProperty property, string key, bool fromStyle) { if (property == null) - throw new ArgumentNullException("property"); + throw new ArgumentNullException(nameof(property)); if (string.IsNullOrEmpty(key)) - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); BindablePropertyContext context = null; if (fromStyle && (context = GetContext(property)) != null && (context.Attributes & BindableContextAttributes.IsDefaultValue) == 0 && diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz56852.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz56852.xaml new file mode 100644 index 00000000..c7c66ef9 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz56852.xaml @@ -0,0 +1,19 @@ +<?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.Bz56852"> + <ContentPage.Resources> + <ResourceDictionary> + <x:Double x:Key="Large">50</x:Double> + <x:Double x:Key="Small">10</x:Double> + <Style x:Key="MyBaseStyle" TargetType="Label"> + <Setter Property="FontSize" Value="{DynamicResource Small}" /> + </Style> + <Style x:Key="MyDerivedStyle" TargetType="Label" BasedOn="{StaticResource MyBaseStyle}"> + <Setter Property="FontSize" Value="{DynamicResource Large}" /> + </Style> + </ResourceDictionary> + </ContentPage.Resources> + + <Label x:Name="label" Text="Hello" Style="{StaticResource MyDerivedStyle}" /> +</ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz56852.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz56852.xaml.cs new file mode 100644 index 00000000..912b8d5c --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz56852.xaml.cs @@ -0,0 +1,44 @@ +using System; +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz56852 + { + public Bz56852() + { + InitializeComponent(); + } + + public Bz56852(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 DynamicResourceApplyingOrder(bool useCompiledXaml) + { + var layout = new Bz56852(useCompiledXaml); + Assert.That(layout.label.FontSize, Is.EqualTo(50)); + } + } + } +} diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj index 8101b38b..d528379e 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj +++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj @@ -488,6 +488,9 @@ <Compile Include="FieldModifier.xaml.cs"> <DependentUpon>FieldModifier.xaml</DependentUpon> </Compile> + <Compile Include="Issues\Bz56852.xaml.cs"> + <DependentUpon>Bz56852.xaml</DependentUpon> + </Compile> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" /> @@ -893,7 +896,10 @@ <EmbeddedResource Include="FieldModifier.xaml"> <Generator>MSBuild:UpdateDesignTimeXaml</Generator> </EmbeddedResource> - </ItemGroup> + <EmbeddedResource Include="Issues\Bz56852.xaml"> + <Generator>MSBuild:UpdateDesignTimeXaml</Generator> + </EmbeddedResource> + </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> </ItemGroup> |