summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj6
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/XamlLoaderCreateTests.cs3
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml6
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml.cs55
4 files changed, 70 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
index 417e800a..cd22258c 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -347,6 +347,9 @@
<Compile Include="SharedResourceDictionary2.xaml.cs">
<DependentUpon>SharedResourceDictionary2.xaml</DependentUpon>
</Compile>
+ <Compile Include="XamlLoaderGetXamlForTypeTests.xaml.cs">
+ <DependentUpon>XamlLoaderGetXamlForTypeTests.xaml</DependentUpon>
+ </Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
@@ -617,6 +620,9 @@
<EmbeddedResource Include="SharedResourceDictionary2.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="XamlLoaderGetXamlForTypeTests.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
diff --git a/Xamarin.Forms.Xaml.UnitTests/XamlLoaderCreateTests.cs b/Xamarin.Forms.Xaml.UnitTests/XamlLoaderCreateTests.cs
index a175b57f..23c72a00 100644
--- a/Xamarin.Forms.Xaml.UnitTests/XamlLoaderCreateTests.cs
+++ b/Xamarin.Forms.Xaml.UnitTests/XamlLoaderCreateTests.cs
@@ -3,6 +3,8 @@ using NUnit.Framework;
namespace Xamarin.Forms.Xaml.UnitTests
{
+#pragma warning disable 0618 //retaining legacy call to obsolete code
+
[TestFixture]
public class XamlLoaderCreateTests
{
@@ -35,4 +37,5 @@ namespace Xamarin.Forms.Xaml.UnitTests
Assert.NotNull (button);
}
}
+#pragma warning restore 0618
} \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml b/Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml
new file mode 100644
index 00000000..ec551771
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml
@@ -0,0 +1,6 @@
+<?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.XamlLoaderGetXamlForTypeTests">
+ <Button x:Name="Button"/>
+</ContentPage>
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>());
+ }
+ }
+ }
+}
+