-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
TypeExtensionTests.cs
55 lines (46 loc) · 1.65 KB
/
TypeExtensionTests.cs
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
using System;
using NUnit.Framework;
using System.Xml;
using Xamarin.Forms.Core.UnitTests;
using System.Reflection;
namespace Xamarin.Forms.Xaml.UnitTests
{
[TestFixture]
public class TypeExtensionTests : BaseTestFixture
{
IXamlTypeResolver typeResolver;
Internals.XamlServiceProvider serviceProvider;
[SetUp]
public override void Setup ()
{
base.Setup ();
var nsManager = new XmlNamespaceManager (new NameTable ());
nsManager.AddNamespace("", "http://xamarin.com/schemas/2014/forms");
nsManager.AddNamespace("local", "clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests");
nsManager.AddNamespace("sys", "clr-namespace:System;assembly=mscorlib");
nsManager.AddNamespace("x", "http://schemas.microsoft.com/winfx/2006/xaml");
typeResolver = new Internals.XamlTypeResolver (nsManager, XamlParser.GetElementType, Assembly.GetCallingAssembly ());
serviceProvider = new Internals.XamlServiceProvider (null, null) {
IXamlTypeResolver = typeResolver,
};
}
[Test]
public void TestxType ()
{
var markupString = @"{x:Type sys:String}";
Assert.AreEqual (typeof(string), (new MarkupExtensionParser ()).ParseExpression (ref markupString, serviceProvider));
}
[Test]
public void TestWithoutPrefix ()
{
var markupString = @"{x:Type Grid}";
Assert.AreEqual (typeof(Grid), (new MarkupExtensionParser ()).ParseExpression (ref markupString, serviceProvider));
}
[Test]
public void TestWithExplicitTypeName ()
{
var markupString = @"{x:Type TypeName=sys:String}";
Assert.AreEqual (typeof(string), (new MarkupExtensionParser ()).ParseExpression (ref markupString, serviceProvider));
}
}
}