summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml.cs
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-07-19 01:17:29 +0200
committerJason Smith <jason.smith@xamarin.com>2016-07-18 16:17:29 -0700
commitf304f25df2d80094d2c31fda4986f92454599a7e (patch)
treee9b9a32bea7e5f8c5e07fbcb4cabbaa5abb0c2f8 /Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml.cs
parent272033723ea275ceb8a288fa605eafd035c79f2d (diff)
downloadxamarin-forms-f304f25df2d80094d2c31fda4986f92454599a7e.tar.gz
xamarin-forms-f304f25df2d80094d2c31fda4986f92454599a7e.tar.bz2
xamarin-forms-f304f25df2d80094d2c31fda4986f92454599a7e.zip
[Xaml] allow the Previewer to provide their own Xaml files for any type (#262)
* [Xaml] allow the Previewer to provide their own Xaml files for any type * [Xaml] use a Func instead of an interface, easier to use by reflection. Add tests * [XamlC] move the InitializeComponent duplication to XamlC task * [XamlC] generate branching code * [XamlC] fix the XamlC issue * [XamlC] make the API public * [docs] fix docs
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml.cs')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml.cs
new file mode 100644
index 00000000..10c3f2e2
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+
+using NUnit.Framework;
+
+using Xamarin.Forms;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public partial class XamlLoaderGetXamlForTypeTests : ContentPage
+ {
+ public XamlLoaderGetXamlForTypeTests()
+ {
+ InitializeComponent();
+ }
+
+ public XamlLoaderGetXamlForTypeTests(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ public class Tests
+ {
+ [SetUp]
+ public void SetUp()
+ {
+ Xamarin.Forms.Xaml.Internals.XamlLoader.XamlFileProvider = null;
+ }
+
+ [TestCase(false)]
+ [TestCase(true)]
+ public void XamlContentIsReplaced(bool useCompiledXaml)
+ {
+ var layout = new XamlLoaderGetXamlForTypeTests(useCompiledXaml);
+ Assert.That(layout.Content, Is.TypeOf<Button>());
+
+ Xamarin.Forms.Xaml.Internals.XamlLoader.XamlFileProvider = (t) => {
+ if (t == typeof(XamlLoaderGetXamlForTypeTests))
+ return @"
+ <ContentPage xmlns=""http://xamarin.com/schemas/2014/forms""
+ xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
+ x:Class=""Xamarin.Forms.Xaml.UnitTests.XamlLoaderGetXamlForTypeTests"">
+ <Label x:Name=""Label""/>
+ </ContentPage>";
+ return null;
+ };
+
+ layout = new XamlLoaderGetXamlForTypeTests(useCompiledXaml);
+ Assert.That(layout.Content, Is.TypeOf<Label>());
+ }
+ }
+ }
+}
+