diff options
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml.cs')
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/XamlLoaderGetXamlForTypeTests.xaml.cs | 55 |
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>()); + } + } + } +} + |