-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
ViewExtensionsTest.cs
59 lines (53 loc) · 1.12 KB
/
ViewExtensionsTest.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
56
57
58
using NUnit.Framework;
using System;
using Xamarin.Forms.Core.UnitTests;
namespace Xamarin.Forms.Xaml.UnitTests
{
[TestFixture]
public class ViewExtensionsTest : BaseTestFixture
{
[Test]
public void TestGetResource ()
{
var resource = new object ();
var view = new View {
Resources = new ResourceDictionary {
{ "foo", resource }
},
};
var found = view.Resources ["foo"];
Assert.AreSame (resource, found);
}
[Test]
public void TestResourceNotFound ()
{
var view = new View ();
var resource = ((IResourcesProvider)view).IsResourcesCreated ? view.Resources ["foo"] : null;
Assert.Null (resource);
}
[Test]
public void TestGetResourceInParents ()
{
var resource = new object ();
var nestedView = new View ();
var stack = new StackLayout {
Children = {
new StackLayout {
Children = {
new StackLayout {
Children = {
nestedView
}
}
}
}
}
};
stack.Resources = new ResourceDictionary {
{ "foo", resource }
};
var found = stack.Resources ["foo"];
Assert.AreSame (resource, found);
}
}
}