blob: e52b5dbf51788acd185a41d21106942600add39f (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace Xamarin.Forms.Core.UnitTests
{
[TestFixture]
public class ContentPageUnitTests : BaseTestFixture
{
[Test]
public void PropagateBindingContextBefore()
{
var stack = new StackLayout();
var content = new ContentPage();
content.Content = stack;
object context = new object();
content.BindingContext = context;
Assert.AreSame (context, stack.BindingContext);
}
[Test]
public void PropagateBindingContextAfter()
{
var stack = new StackLayout();
var content = new ContentPage();
object context = new object();
content.BindingContext = context;
content.Content = stack;
Assert.AreSame (context, stack.BindingContext);
}
[Test]
public void PropagateToolbarItemBindingContextPreAdd ()
{
var page = new ContentPage ();
object context = "hello";
var toolbarItem = new ToolbarItem ();
page.ToolbarItems.Add (toolbarItem);
page.BindingContext = context;
Assert.AreEqual (context, toolbarItem.BindingContext);
}
[Test]
public void PropagateToolbarItemBindingContextPostAdd ()
{
var page = new ContentPage ();
object context = "hello";
var toolbarItem = new ToolbarItem ();
page.BindingContext = context;
page.ToolbarItems.Add (toolbarItem);
Assert.AreEqual (context, toolbarItem.BindingContext);
}
[Test]
public void ContentPage_should_have_the_InternalChildren_correctly_when_Content_changed()
{
var sut = new ContentPage();
IList<Element> internalChildren = ((IControlTemplated)sut).InternalChildren;
internalChildren.Add(new VisualElement());
internalChildren.Add(new VisualElement());
internalChildren.Add(new VisualElement());
var expected = new View();
sut.Content = expected;
Assert.AreEqual(1, internalChildren.Count);
Assert.AreSame(expected, internalChildren[0]);
}
}
}
|