From 3ab20b658d4e07ebd8b3cf149fd06e5b71420248 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Mon, 8 Jun 2020 20:29:09 -0600 Subject: [PATCH] unit tests for topologicalsort errors --- UnitTests/ViewTests.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/UnitTests/ViewTests.cs b/UnitTests/ViewTests.cs index 059544090..f89cbf6d3 100644 --- a/UnitTests/ViewTests.cs +++ b/UnitTests/ViewTests.cs @@ -107,5 +107,33 @@ namespace Terminal.Gui { // TODO: Add more } + + [Fact] + public void TopologicalSort_Missing_Add () + { + var root = new View (); + var sub1 = new View (); + root.Add (sub1); + var sub2 = new View (); + sub1.Width = Dim.Width(sub2); + + Assert.Throws (() => root.LayoutSubviews ()); + + sub2.Width = Dim.Width (sub1); + + Assert.Throws (() => root.LayoutSubviews ()); + } + + [Fact] + public void TopologicalSort_Recursive_Ref () + { + var root = new View (); + var sub1 = new View (); + root.Add (sub1); + var sub2 = new View (); + root.Add (sub2); + sub2.Width = Dim.Width (sub2); + Assert.Throws (() => root.LayoutSubviews ()); + } } }