This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathTableViewUnitTests.cs
82 lines (66 loc) · 1.71 KB
/
TableViewUnitTests.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System.Linq;
using NUnit.Framework;
namespace Xamarin.Forms.Core.UnitTests
{
[TestFixture]
public class TableViewUnitTests : BaseTestFixture
{
[Test]
public void TestConstructor()
{
var table = new TableView();
Assert.False(table.Root.Any());
Assert.AreEqual(LayoutOptions.FillAndExpand, table.HorizontalOptions);
Assert.AreEqual(LayoutOptions.FillAndExpand, table.VerticalOptions);
}
[Test]
public void TestModelChanged()
{
var table = new TableView();
bool changed = false;
table.ModelChanged += (sender, e) => changed = true;
table.Root = new TableRoot("NewRoot");
Assert.True(changed);
}
[Test]
public void BindingsContextChainsToModel()
{
const string context = "Context";
var table = new TableView { BindingContext = context, Root = new TableRoot() };
Assert.AreEqual(context, table.Root.BindingContext);
// reverse assignment order
table = new TableView { Root = new TableRoot(), BindingContext = context };
Assert.AreEqual(context, table.Root.BindingContext);
}
[Test]
public void ParentsViewCells()
{
ViewCell viewCell = new ViewCell { View = new Label() };
var table = new TableView
{
Root = new TableRoot {
new TableSection {
viewCell
}
}
};
Assert.AreEqual(table, viewCell.Parent);
Assert.AreEqual(viewCell, viewCell.View.Parent);
}
[Test]
public void ParentsAddedViewCells()
{
var viewCell = new ViewCell { View = new Label() };
var section = new TableSection();
var table = new TableView
{
Root = new TableRoot {
section
}
};
section.Add(viewCell);
Assert.AreEqual(table, viewCell.Parent);
Assert.AreEqual(viewCell, viewCell.View.Parent);
}
}
}