diff options
Diffstat (limited to 'Xamarin.Forms.Core.UnitTests/ViewCellTests.cs')
-rw-r--r-- | Xamarin.Forms.Core.UnitTests/ViewCellTests.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/ViewCellTests.cs b/Xamarin.Forms.Core.UnitTests/ViewCellTests.cs new file mode 100644 index 00000000..2a8647d4 --- /dev/null +++ b/Xamarin.Forms.Core.UnitTests/ViewCellTests.cs @@ -0,0 +1,65 @@ +using System; +using NUnit.Framework; + + +namespace Xamarin.Forms.Core.UnitTests +{ + [TestFixture] + public class ViewCellTests : BaseTestFixture + { + [Test] + public void SetParentBeforeView () + { + var parent = new View { Platform = new UnitPlatform () }; + var child = new View (); + var viewCell = new ViewCell (); + + Assert.Null (viewCell.View); + Assert.DoesNotThrow (() => viewCell.Parent = parent); + + viewCell.View = child; + Assert.AreSame (parent, viewCell.Parent); + Assert.AreSame (viewCell, child.Parent); + Assert.AreSame (parent.Platform, child.Platform); + } + + [Test] + //issue 550 + public void SetBindingContextBeforeParent () + { + var parent = new View { + Platform = new UnitPlatform (), + BindingContext = new object (), + }; + + var itemcontext = new object (); + var cell = new ViewCell { View = new Label ()}; + cell.BindingContext = itemcontext; + cell.Parent = parent; + + Assert.AreSame (itemcontext, cell.View.BindingContext); + } + + [Test] + public void SetBindingContextBeforeView () + { + var context = new object (); + var view = new View (); + var cell = new ViewCell (); + cell.BindingContext = context; + cell.View = view; + Assert.AreSame (context, view.BindingContext); + } + + [Test] + public void SetViewBeforeBindingContext () + { + var context = new object (); + var view = new View (); + var cell = new ViewCell (); + cell.View = view; + cell.BindingContext = context; + Assert.AreSame (context, view.BindingContext); + } + } +} |