[XamlC] passing test for 47703
authorStephane Delcroix <stephane@delcroix.org>
Fri, 2 Dec 2016 20:36:10 +0000 (21:36 +0100)
committerStephane Delcroix <stephane@delcroix.org>
Fri, 2 Dec 2016 20:36:10 +0000 (21:36 +0100)
Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml [new file with mode: 0644]
Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml.cs [new file with mode: 0644]
Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj

diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz47703.xaml
new file mode 100644 (file)
index 0000000..75da95a
--- /dev/null
@@ -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 (file)
index 0000000..a661e3d
--- /dev/null
@@ -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
index 7886649..9c2776e 100644 (file)
     <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" />
     <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}" />