summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-12-02 21:36:10 +0100
committerStephane Delcroix <stephane@delcroix.org>2016-12-02 21:36:10 +0100
commitbadc701871a1190d6acb3495d3cefa93cff810c5 (patch)
treec3149d479da2a712ed2a30405b6143d07e58ea7d /Xamarin.Forms.Xaml.UnitTests
parent0dc9fed3f98ae3eba7ff4e8052a55666a14da32d (diff)
downloadxamarin-forms-badc701871a1190d6acb3495d3cefa93cff810c5.tar.gz
xamarin-forms-badc701871a1190d6acb3495d3cefa93cff810c5.tar.bz2
xamarin-forms-badc701871a1190d6acb3495d3cefa93cff810c5.zip
[XamlC] passing test for 47703
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml13
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml.cs63
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj6
3 files changed, 82 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml
new file mode 100644
index 00000000..75da95ae
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml
@@ -0,0 +1,13 @@
+<?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.Bz47703">
+ <ContentPage.Resources>
+ <ResourceDictionary>
+ <local:Bz47703Converter x:Key="converter" />
+ </ResourceDictionary>
+ </ContentPage.Resources>
+ <local:Bz47703View x:Name="view" DisplayBinding="{Binding Name, Converter={StaticResource converter}}" />
+</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml.cs
new file mode 100644
index 00000000..a661e3da
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml.cs
@@ -0,0 +1,63 @@
+´╗┐using System;
+using System.Globalization;
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public class Bz47703Converter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null)
+ return "Label:" + value;
+ return value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value;
+ }
+ }
+
+ public class Bz47703View : Label
+ {
+ BindingBase displayBinding;
+
+ public BindingBase DisplayBinding {
+ get { return displayBinding; }
+ set {
+ displayBinding = value;
+ if (displayBinding != null)
+ this.SetBinding(TextProperty, DisplayBinding);
+ }
+ }
+ }
+
+ public partial class Bz47703 : ContentPage
+ {
+ public Bz47703()
+ {
+ InitializeComponent();
+ }
+
+ public Bz47703(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ class Tests
+ {
+ [TestCase(true)]
+ [TestCase(false)]
+ public void IValueConverterOnBindings(bool useCompiledXaml)
+ {
+ if (useCompiledXaml)
+ MockCompiler.Compile(typeof(Bz47703));
+ var page = new Bz47703(useCompiledXaml);
+ page.BindingContext = new { Name = "Foo" };
+ Assert.AreEqual("Label:Foo", page.view.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 7886649c..9c2776ec 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -388,6 +388,9 @@
<Compile Include="Issues\Unreported007.xaml.cs">
<DependentUpon>Unreported007.xaml</DependentUpon>
</Compile>
+ <Compile Include="Issues\Bz47703.xaml.cs">
+ <DependentUpon>Bz47703.xaml</DependentUpon>
+ </Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
@@ -697,6 +700,9 @@
<EmbeddedResource Include="Issues\Unreported007.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="Issues\Bz47703.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />