diff options
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests/DefaultCtorRouting.xaml.cs')
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/DefaultCtorRouting.xaml.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/DefaultCtorRouting.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/DefaultCtorRouting.xaml.cs new file mode 100644 index 00000000..250eed72 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/DefaultCtorRouting.xaml.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using Mono.Cecil; +using Mono.Cecil.Cil; +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; +using Xamarin.Forms.Xaml; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [XamlCompilation(XamlCompilationOptions.Skip)] + public partial class DefaultCtorRouting : ContentPage + { + [TypeConverter(typeof(IsCompiledTypeConverter))] + public bool IsCompiled { get; set; } + + public DefaultCtorRouting() + { + InitializeComponent(); + } + + [TestFixture] + class Tests + { + [SetUp] + public void Setup() + { + Device.PlatformServices = new MockPlatformServices(); + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; + } + + [Test] + public void ShouldntBeCompiled() + { + var p = new DefaultCtorRouting(); + Assert.False(p.IsCompiled); + } + } + } + + [ProvideCompiled("Xamarin.Forms.Core.XamlC.IsCompiledTypeConverter")] + class IsCompiledTypeConverter : TypeConverter, ICompiledTypeConverter + { + public override object ConvertFromInvariantString(string value) + { + if (value != "IsCompiled?") + throw new Exception(); + return false; + } + + public IEnumerable<Instruction> ConvertFromString(string value, ModuleDefinition module, BaseNode node) + { + if (value != "IsCompiled?") + throw new Exception(); + yield return Instruction.Create(OpCodes.Ldc_I4_1); + } + } +}
\ No newline at end of file |