summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.UnitTests/TemplatedViewUnitTests.cs
diff options
context:
space:
mode:
authorwplong11 <wplong11@naver.com>2017-03-20 21:06:20 +0900
committerRui Marinho <me@ruimarinho.net>2017-03-20 12:06:20 +0000
commitf98e1525c15ca77ec9840c2b5c8020b1b320b141 (patch)
tree46bbe9afc82c275da3828f486dcf63821f7e2a0a /Xamarin.Forms.Core.UnitTests/TemplatedViewUnitTests.cs
parentce068193286c5fcebe3fe01fd5edfbbac88e4058 (diff)
downloadxamarin-forms-f98e1525c15ca77ec9840c2b5c8020b1b320b141.tar.gz
xamarin-forms-f98e1525c15ca77ec9840c2b5c8020b1b320b141.tar.bz2
xamarin-forms-f98e1525c15ca77ec9840c2b5c8020b1b320b141.zip
[Core] Fix internal children clear logic (#820)
* Fix InternalChildren clear logic * Improve InternalChildren clear logic * Add test code to verify InternalChildren clear logic * Add missing test cases * Improve time complexity of clear logic * Fix the test case where InvalidOperationException occurs. * Correct the name casing of the test case * Modify a wrong test code
Diffstat (limited to 'Xamarin.Forms.Core.UnitTests/TemplatedViewUnitTests.cs')
-rw-r--r--Xamarin.Forms.Core.UnitTests/TemplatedViewUnitTests.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/TemplatedViewUnitTests.cs b/Xamarin.Forms.Core.UnitTests/TemplatedViewUnitTests.cs
new file mode 100644
index 00000000..6255edaf
--- /dev/null
+++ b/Xamarin.Forms.Core.UnitTests/TemplatedViewUnitTests.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Core.UnitTests
+{
+ [TestFixture]
+ public class TemplatedViewUnitTests : BaseTestFixture
+ {
+ [Test]
+ public void TemplatedView_should_have_the_InternalChildren_correctly_when_ControlTemplate_changed()
+ {
+ var sut = new TemplatedView();
+ IList<Element> internalChildren = ((IControlTemplated)sut).InternalChildren;
+ internalChildren.Add(new VisualElement());
+ internalChildren.Add(new VisualElement());
+ internalChildren.Add(new VisualElement());
+
+ sut.ControlTemplate = new ControlTemplate(typeof(ExpectedView));
+
+ Assert.AreEqual(1, internalChildren.Count);
+ Assert.IsInstanceOf<ExpectedView>(internalChildren[0]);
+ }
+
+ private class ExpectedView : View
+ {
+ public ExpectedView()
+ {
+ }
+ }
+ }
+}