blob: 250eed72427847bd2bc880b1921e245163dd101c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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);
}
}
}
|