Browse Source

Added and Removing tests.

BDisp 5 years ago
parent
commit
cffdba52c9
1 changed files with 21 additions and 0 deletions
  1. 21 0
      UnitTests/ViewTests.cs

+ 21 - 0
UnitTests/ViewTests.cs

@@ -135,5 +135,26 @@ namespace Terminal.Gui {
 			sub2.Width = Dim.Width (sub2);
 			Assert.Throws<InvalidOperationException> (() => root.LayoutSubviews ());
 		}
+
+		[Fact]
+		public void Added_Removing ()
+		{
+			var v = new View (new Rect (0, 0, 10, 24));
+			var t = new View ();
+
+			v.Added += (View e) => {
+				Assert.True (v.SuperView == e);
+			};
+
+			v.Removing += (View e) => {
+				Assert.True (v.SuperView == e);
+			};
+
+			t.Add (v);
+			Assert.True (t.Subviews.Count == 1);
+
+			t.Remove (v);
+			Assert.True (t.Subviews.Count == 0);
+		}
 	}
 }