summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-02-02 11:14:35 +0100
committerKangho Hur <kangho.hur@samsung.com>2017-03-24 13:18:32 +0900
commitfc482ef2eb128dae25342613a3e6d6d0f676419a (patch)
treee39be7f3b0728573a9e791f04571728a8ec8d186 /Xamarin.Forms.Xaml.UnitTests
parentd76030e441b0b64aa6aaaea7cdaab243161da535 (diff)
downloadxamarin-forms-fc482ef2eb128dae25342613a3e6d6d0f676419a.tar.gz
xamarin-forms-fc482ef2eb128dae25342613a3e6d6d0f676419a.tar.bz2
xamarin-forms-fc482ef2eb128dae25342613a3e6d6d0f676419a.zip
[Xaml[C]] throw meaningful exception while trying to set the content … (#714)
* [Xaml[C]] throw meaningful exception while trying to set the content of a property without ContentPropertyAttribute * fix test
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz43694.xaml21
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz43694.xaml.cs48
2 files changed, 69 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43694.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43694.xaml
new file mode 100644
index 00000000..9fcc0c00
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43694.xaml
@@ -0,0 +1,21 @@
+<?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.Bz43694">
+ <ContentPage.Resources>
+ <ResourceDictionary>
+ <x:String x:Key="Dark">Dark</x:String>
+ <x:String x:Key="Light">
+ <OnPlatform x:TypeArguments="x:String">
+ <OnPlatform.iOS>OpenSans-Light</OnPlatform.iOS>
+ <OnPlatform.Android>OpenSans-Light</OnPlatform.Android>
+ <OnPlatform.WinPhone>/Assets/Fonts/OpenSans-Light.ttf#Open Sans</OnPlatform.WinPhone>
+ </OnPlatform>
+ </x:String>
+ </ResourceDictionary>
+ </ContentPage.Resources>
+ <Label Text="{StaticResource Light}"
+ VerticalOptions="Center"
+ HorizontalOptions="Center"
+ x:Name="label"/>
+</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43694.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43694.xaml.cs
new file mode 100644
index 00000000..62af1c0b
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43694.xaml.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using Xamarin.Forms;
+using Xamarin.Forms.Core.UnitTests;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ [XamlCompilation(XamlCompilationOptions.Skip)]
+ public partial class Bz43694 : ContentPage
+ {
+ public Bz43694()
+ {
+ InitializeComponent();
+ }
+
+ public Bz43694(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 xStaticWithOnPlatformChildInRD(bool useCompiledXaml)
+ {
+ if (useCompiledXaml)
+ Assert.Throws(new XamlParseExceptionConstraint(9, 6), () => MockCompiler.Compile(typeof(Bz43694)));
+ else
+ Assert.Throws(new XamlParseExceptionConstraint(9, 6), () => new Bz43694(useCompiledXaml));
+ }
+ }
+ }
+} \ No newline at end of file