summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.UnitTests/TableViewUnitTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core.UnitTests/TableViewUnitTests.cs')
-rw-r--r--Xamarin.Forms.Core.UnitTests/TableViewUnitTests.cs84
1 files changed, 84 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/TableViewUnitTests.cs b/Xamarin.Forms.Core.UnitTests/TableViewUnitTests.cs
new file mode 100644
index 00000000..7e5ca496
--- /dev/null
+++ b/Xamarin.Forms.Core.UnitTests/TableViewUnitTests.cs
@@ -0,0 +1,84 @@
+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 {
+ Platform = new UnitPlatform (),
+ Root = new TableRoot {
+ new TableSection {
+ viewCell
+ }
+ }
+ };
+
+ Assert.AreEqual (table, viewCell.Parent);
+ Assert.AreEqual (viewCell, viewCell.View.Parent);
+ Assert.AreEqual (table.Platform, viewCell.View.Platform);
+ }
+
+ [Test]
+ public void ParentsAddedViewCells ()
+ {
+ var viewCell = new ViewCell { View = new Label () };
+ var section = new TableSection ();
+ var table = new TableView {
+ Platform = new UnitPlatform (),
+ Root = new TableRoot {
+ section
+ }
+ };
+
+ section.Add (viewCell);
+
+ Assert.AreEqual (table, viewCell.Parent);
+ Assert.AreEqual (viewCell, viewCell.View.Parent);
+ Assert.AreEqual (table.Platform, viewCell.View.Platform);
+ }
+ }
+}