using System; using NUnit.Framework; using Xamarin.Forms.Core.UnitTests; namespace Xamarin.Forms.Xaml.UnitTests { [TestFixture] public class Issue1554 { [SetUp] public void Setup() { Device.PlatformServices = new MockPlatformServices(); } [TearDown] public void TearDown() { Device.PlatformServices = null; } [Test] public void CollectionItemsInDataTemplate () { var xaml = @" "; var listview = new ListView (); var items = new [] { "Foo", "Bar", "Baz" }; listview.BindingContext = items; listview.LoadFromXaml (xaml); ViewCell cell0 = null; Assert.DoesNotThrow (() => { cell0 = (ViewCell)listview.TemplatedItems.GetOrCreateContent (0, items [0]); }); ViewCell cell1 = null; Assert.DoesNotThrow (() => { cell1 = (ViewCell)listview.TemplatedItems.GetOrCreateContent (1, items [1]); }); Assert.AreNotSame (cell0, cell1); Assert.AreNotSame (cell0.View, cell1.View); Assert.AreNotSame (((StackLayout)cell0.View).Children [0], ((StackLayout)cell1.View).Children [0]); Assert.AreNotSame (((StackLayout)cell0.View).Children [1], ((StackLayout)cell1.View).Children [1]); } } }