summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-04-12 18:46:39 +0200
committerJason Smith <jason.smith@xamarin.com>2016-04-12 09:46:39 -0700
commitc92297047c01112fd4a6e7695a40acb274fdf7a7 (patch)
tree413ce7f7a6d0507ff55ac237365924f55c49b345 /Xamarin.Forms.Xaml.UnitTests
parentf975a6f2e3552c3309c8e10f15998be664d06882 (diff)
downloadxamarin-forms-c92297047c01112fd4a6e7695a40acb274fdf7a7.tar.gz
xamarin-forms-c92297047c01112fd4a6e7695a40acb274fdf7a7.tar.bz2
xamarin-forms-c92297047c01112fd4a6e7695a40acb274fdf7a7.zip
[X] internal CreateFromXaml () (#77)
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/TypeConverterTestsLegacy.cs12
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj1
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/XamlLoaderCreateTests.cs38
3 files changed, 45 insertions, 6 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/TypeConverterTestsLegacy.cs b/Xamarin.Forms.Xaml.UnitTests/TypeConverterTestsLegacy.cs
index 9d5051f3..4066bb28 100644
--- a/Xamarin.Forms.Xaml.UnitTests/TypeConverterTestsLegacy.cs
+++ b/Xamarin.Forms.Xaml.UnitTests/TypeConverterTestsLegacy.cs
@@ -123,7 +123,7 @@ namespace Xamarin.Forms.Xaml.UnitTests
var bindable = new Bindable ();
Assert.IsNull (bindable.Baz);
- var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable) {
+ var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable, null) {
Properties = {
{ new XmlName (null, "Baz"), node },
}
@@ -142,7 +142,7 @@ namespace Xamarin.Forms.Xaml.UnitTests
var bindable = new Bindable ();
Assert.IsNull (bindable.Baz);
- var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable) {
+ var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable, null) {
Properties = {
{ new XmlName (null, "Baz"), node },
}
@@ -159,7 +159,7 @@ namespace Xamarin.Forms.Xaml.UnitTests
var bindable = new Bindable ();
Assert.IsNull (bindable.Foo);
- var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable) {
+ var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable, null) {
Properties = {
{ new XmlName (null, "Foo"), node },
}
@@ -180,7 +180,7 @@ namespace Xamarin.Forms.Xaml.UnitTests
var bindable = new Bindable ();
Assert.IsNull (bindable.Bar);
- var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable) {
+ var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable, null) {
Properties = {
{ new XmlName (null, "Bar"), node },
}
@@ -200,7 +200,7 @@ namespace Xamarin.Forms.Xaml.UnitTests
var bindable = new Bindable ();
Assert.IsNull (Bindable.GetQux (bindable));
- var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable) {
+ var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable, null) {
Properties = {
{ new XmlName ("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests", "Bindable.Qux"), node },
}
@@ -220,7 +220,7 @@ namespace Xamarin.Forms.Xaml.UnitTests
var bindable = new Bindable ();
Assert.IsNull (bindable.FooBar);
- var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable) {
+ var rootNode = new XamlLoader.RuntimeRootNode (new XmlType("clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests","Bindable",null), bindable, null) {
Properties = {
{ new XmlName (null, "FooBar"), node },
}
diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
index ff6ebee4..226e8bb8 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -334,6 +334,7 @@
<Compile Include="McIgnorable.xaml.cs">
<DependentUpon>McIgnorable.xaml</DependentUpon>
</Compile>
+ <Compile Include="XamlLoaderCreateTests.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
diff --git a/Xamarin.Forms.Xaml.UnitTests/XamlLoaderCreateTests.cs b/Xamarin.Forms.Xaml.UnitTests/XamlLoaderCreateTests.cs
new file mode 100644
index 00000000..a175b57f
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/XamlLoaderCreateTests.cs
@@ -0,0 +1,38 @@
+´╗┐using System;
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ [TestFixture]
+ public class XamlLoaderCreateTests
+ {
+ [Test]
+ public void CreateFromXaml ()
+ {
+ var xaml = @"
+ <ContentView xmlns=""http://xamarin.com/schemas/2014/forms""
+ xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
+ x:Class=""Xamarin.Forms.Xaml.UnitTests.FOO"">
+ <Label Text=""Foo"" x:Name=""label""/>
+ </ContentView>";
+
+ var view = XamlLoader.Create (xaml);
+ Assert.That (view, Is.TypeOf<ContentView> ());
+ Assert.AreEqual ("Foo", ((Label)((ContentView)view).Content).Text);
+ }
+
+ [Test]
+ public void CreateFromXamlDoesntFailOnMissingEventHandler ()
+ {
+ var xaml = @"
+ <Button xmlns=""http://xamarin.com/schemas/2014/forms""
+ xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
+ Clicked=""handleClick"">
+ </Button>";
+
+ Button button = null;
+ Assert.DoesNotThrow (() => button = XamlLoader.Create (xaml, true) as Button);
+ Assert.NotNull (button);
+ }
+ }
+} \ No newline at end of file