diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2017-02-01 17:03:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-01 17:03:53 +0100 |
commit | d598d5efe3ead3b57b18421253ccf05eefacfdd0 (patch) | |
tree | 9cfe45f78e71a1bbd8245019eb0ab1f3a01ee1c2 /Xamarin.Forms.Xaml.UnitTests | |
parent | ae59382c9046501edb37882ad1c065aacce60319 (diff) | |
download | xamarin-forms-d598d5efe3ead3b57b18421253ccf05eefacfdd0.tar.gz xamarin-forms-d598d5efe3ead3b57b18421253ccf05eefacfdd0.tar.bz2 xamarin-forms-d598d5efe3ead3b57b18421253ccf05eefacfdd0.zip |
[Xaml[C]] cast to BindingBase before SetBinding() (#709)
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
3 files changed, 66 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz44213.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz44213.xaml new file mode 100644 index 00000000..0a932f32 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz44213.xaml @@ -0,0 +1,12 @@ +<?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.Bz44213"> + <Label x:Name="label"> + <Label.Text> + <OnPlatform x:TypeArguments="BindingBase" Android="{Binding Bar}"> + <OnPlatform.iOS> + <Binding Path="Foo"/> + </OnPlatform.iOS> + </OnPlatform> + </Label.Text> + </Label> +</ContentPage> diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz44213.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz44213.xaml.cs new file mode 100644 index 00000000..faabad6d --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz44213.xaml.cs @@ -0,0 +1,48 @@ +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Bz44213 : ContentPage + { + public Bz44213() + { + InitializeComponent(); + } + + public Bz44213(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; + } + + [TestCase(true)] + [TestCase(false)] + public void BindingInOnPlatform(bool useCompiledXaml) + { + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; + var p = new Bz44213(useCompiledXaml); + p.BindingContext = new { Foo = "Foo", Bar = "Bar" }; + Assert.AreEqual("Foo", p.label.Text); + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; + p = new Bz44213(useCompiledXaml); + p.BindingContext = new { Foo = "Foo", Bar = "Bar" }; + Assert.AreEqual("Bar", p.label.Text); + } + } + } +}
\ 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 631d0010..5649861b 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj +++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj @@ -424,6 +424,9 @@ <Compile Include="Issues\Bz43733.xaml.cs"> <DependentUpon>Bz43733.xaml</DependentUpon> </Compile> + <Compile Include="Issues\Bz44213.xaml.cs"> + <DependentUpon>Bz44213.xaml</DependentUpon> + </Compile> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" /> @@ -769,6 +772,9 @@ <EmbeddedResource Include="Issues\Bz43733.xaml"> <Generator>MSBuild:UpdateDesignTimeXaml</Generator> </EmbeddedResource> + <EmbeddedResource Include="Issues\Bz44213.xaml"> + <Generator>MSBuild:UpdateDesignTimeXaml</Generator> + </EmbeddedResource> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> |