Pārlūkot izejas kodu

Merge pull request #652 from tig/unit_test_update

Unit test update
Charlie Kindel 5 gadi atpakaļ
vecāks
revīzija
4116625f88

+ 2 - 2
Terminal.Gui/ConsoleDrivers/MockDriver/MockConsole.cs → Terminal.Gui/ConsoleDrivers/FakeDriver/FakeConsole.cs

@@ -1,5 +1,5 @@
 //
-// MockConsole.cs: A mock .NET Windows Console API implementaiton for unit tests.
+// FakeConsole.cs: A fake .NET Windows Console API implementaiton for unit tests.
 //
 // Authors:
 //   Charlie Kindel (github.com/tig)
@@ -15,7 +15,7 @@ namespace Terminal.Gui {
 	/// <summary>
 	/// 
 	/// </summary>
-	public static class MockConsole {
+	public static class FakeConsole {
 
 		//
 		// Summary:

+ 25 - 25
Terminal.Gui/ConsoleDrivers/MockDriver/MockDriver.cs → Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs

@@ -1,5 +1,5 @@
 //
-// MockDriver.cs: A mock ConsoleDriver for unit tests.
+// FakeDriver.cs: A fake ConsoleDriver for unit tests. 
 //
 // Authors:
 //   Charlie Kindel (github.com/tig)
@@ -14,7 +14,7 @@ namespace Terminal.Gui {
 	/// <summary>
 	/// Implements a mock ConsoleDriver for unit testing
 	/// </summary>
-	public class MockDriver : ConsoleDriver, IMainLoopDriver {
+	public class FakeDriver : ConsoleDriver, IMainLoopDriver {
 		int cols, rows;
 		/// <summary>
 		/// 
@@ -52,10 +52,10 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// 
 		/// </summary>
-		public MockDriver ()
+		public FakeDriver ()
 		{
-			cols = MockConsole.WindowWidth;
-			rows = MockConsole.WindowHeight; // - 1;
+			cols = FakeConsole.WindowWidth;
+			rows = FakeConsole.WindowHeight; // - 1;
 			UpdateOffscreen ();
 		}
 
@@ -73,12 +73,12 @@ namespace Terminal.Gui {
 			crow = row;
 
 			if (Clip.Contains (col, row)) {
-				MockConsole.CursorTop = row;
-				MockConsole.CursorLeft = col;
+				FakeConsole.CursorTop = row;
+				FakeConsole.CursorLeft = col;
 				needMove = false;
 			} else {
-				MockConsole.CursorTop = Clip.Y;
-				MockConsole.CursorLeft = Clip.X;
+				FakeConsole.CursorTop = Clip.Y;
+				FakeConsole.CursorLeft = Clip.X;
 				needMove = true;
 			}
 
@@ -127,8 +127,8 @@ namespace Terminal.Gui {
 		/// </summary>
 		public override void End ()
 		{
-			MockConsole.ResetColor ();
-			MockConsole.Clear ();
+			FakeConsole.ResetColor ();
+			FakeConsole.Clear ();
 		}
 
 		static Attribute MakeColor (ConsoleColor f, ConsoleColor b)
@@ -230,10 +230,10 @@ namespace Terminal.Gui {
 			      .OfType<ConsoleColor> ()
 			      .Select (s => (int)s);
 			if (values.Contains (color & 0xffff)) {
-				MockConsole.BackgroundColor = (ConsoleColor)(color & 0xffff);
+				FakeConsole.BackgroundColor = (ConsoleColor)(color & 0xffff);
 			}
 			if (values.Contains ((color >> 16) & 0xffff)) {
-				MockConsole.ForegroundColor = (ConsoleColor)((color >> 16) & 0xffff);
+				FakeConsole.ForegroundColor = (ConsoleColor)((color >> 16) & 0xffff);
 			}
 		}
 
@@ -245,8 +245,8 @@ namespace Terminal.Gui {
 			int rows = Rows;
 			int cols = Cols;
 
-			MockConsole.CursorTop = 0;
-			MockConsole.CursorLeft = 0;
+			FakeConsole.CursorTop = 0;
+			FakeConsole.CursorLeft = 0;
 			for (int row = 0; row < rows; row++) {
 				dirtyLine [row] = false;
 				for (int col = 0; col < cols; col++) {
@@ -254,7 +254,7 @@ namespace Terminal.Gui {
 					var color = contents [row, col, 1];
 					if (color != redrawColor)
 						SetColor (color);
-					MockConsole.Write ((char)contents [row, col, 0]);
+					FakeConsole.Write ((char)contents [row, col, 0]);
 				}
 			}
 		}
@@ -267,8 +267,8 @@ namespace Terminal.Gui {
 			int rows = Rows;
 			int cols = Cols;
 
-			var savedRow = MockConsole.CursorTop;
-			var savedCol = MockConsole.CursorLeft;
+			var savedRow = FakeConsole.CursorTop;
+			var savedCol = FakeConsole.CursorLeft;
 			for (int row = 0; row < rows; row++) {
 				if (!dirtyLine [row])
 					continue;
@@ -277,20 +277,20 @@ namespace Terminal.Gui {
 					if (contents [row, col, 2] != 1)
 						continue;
 
-					MockConsole.CursorTop = row;
-					MockConsole.CursorLeft = col;
+					FakeConsole.CursorTop = row;
+					FakeConsole.CursorLeft = col;
 					for (; col < cols && contents [row, col, 2] == 1; col++) {
 						var color = contents [row, col, 1];
 						if (color != redrawColor)
 							SetColor (color);
 
-						MockConsole.Write ((char)contents [row, col, 0]);
+						FakeConsole.Write ((char)contents [row, col, 0]);
 						contents [row, col, 2] = 0;
 					}
 				}
 			}
-			MockConsole.CursorTop = savedRow;
-			MockConsole.CursorLeft = savedCol;
+			FakeConsole.CursorTop = savedRow;
+			FakeConsole.CursorLeft = savedCol;
 		}
 
 		/// <summary>
@@ -421,7 +421,7 @@ namespace Terminal.Gui {
 		public override void PrepareToRun (MainLoop mainLoop, Action<KeyEvent> keyHandler, Action<KeyEvent> keyDownHandler, Action<KeyEvent> keyUpHandler, Action<MouseEvent> mouseHandler)
 		{
 			// Note: Net doesn't support keydown/up events and thus any passed keyDown/UpHandlers will never be called
-			(mainLoop.Driver as MockDriver).WindowsKeyPressed = delegate (ConsoleKeyInfo consoleKey) {
+			(mainLoop.Driver as FakeDriver).WindowsKeyPressed = delegate (ConsoleKeyInfo consoleKey) {
 				var map = MapKey (consoleKey);
 				if (map == (Key)0xffffffff)
 					return;
@@ -478,7 +478,7 @@ namespace Terminal.Gui {
 		{
 			while (true) {
 				waitForProbe.WaitOne ();
-				windowsKeyResult = MockConsole.ReadKey (true);
+				windowsKeyResult = FakeConsole.ReadKey (true);
 				keyReady.Set ();
 			}
 		}

+ 16 - 5
Terminal.Gui/Core/PosDim.cs

@@ -222,7 +222,7 @@ namespace Terminal.Gui {
 
 			public override string ToString ()
 			{
-				return $"Pos.Combine ({left.ToString ()}{(add ? '+' : '-')}{right.ToString ()})";
+				return $"Pos.Combine({left.ToString ()}{(add ? '+' : '-')}{right.ToString ()})";
 			}
 
 		}
@@ -274,7 +274,7 @@ namespace Terminal.Gui {
 			}
 			internal override int Anchor (int width)
 			{
-				switch (side) {
+				switch(side) {
 				case 0: return Target.Frame.X;
 				case 1: return Target.Frame.Y;
 				case 2: return Target.Frame.Right;
@@ -287,14 +287,14 @@ namespace Terminal.Gui {
 			public override string ToString ()
 			{
 				string tside;
-				switch (side) {
+				switch(side) {
 				case 0: tside = "x"; break;
 				case 1: tside = "y"; break;
 				case 2: tside = "right"; break;
 				case 3: tside = "bottom"; break;
 				default: tside = "unknown"; break;
 				}
-				return $"Pos.View(side={tside}, target={Target.ToString ()}";
+				return $"Pos.View(side={tside}, target={Target.ToString ()})";
 			}
 		}
 
@@ -538,9 +538,20 @@ namespace Terminal.Gui {
 				this.side = side;
 			}
 
+			public override string ToString ()
+			{
+				string tside;
+				switch(side) {
+				case 0: tside = "Height"; break;
+				case 1: tside = "Width"; break;
+				default: tside = "unknown"; break;
+				}
+				return $"DimView(side={tside}, target={Target.ToString ()})";
+			}
+
 			internal override int Anchor (int width)
 			{
-				switch (side) {
+				switch(side) {
 				case 0: return Target.Frame.Height;
 				case 1: return Target.Frame.Width;
 				default:

+ 12 - 12
UnitTests/ApplicationTests.cs

@@ -5,7 +5,7 @@ using Terminal.Gui;
 using Xunit;
 
 // Alais Console to MockConsole so we don't accidentally use Console
-using Console = Terminal.Gui.MockConsole;
+using Console = Terminal.Gui.FakeConsole;
 
 // Since Application is a singleton we can't run tests in parallel
 [assembly: CollectionBehavior (DisableTestParallelization = true)]
@@ -13,7 +13,7 @@ using Console = Terminal.Gui.MockConsole;
 namespace Terminal.Gui {
 	public class ApplicationTests {
 		[Fact]
-		public void TestInitShutdown ()
+		public void Init_Shutdown_Cleans_Up ()
 		{
 			Assert.Null (Application.Current);
 			Assert.Null (Application.CurrentView);
@@ -21,7 +21,7 @@ namespace Terminal.Gui {
 			Assert.Null (Application.MainLoop);
 			Assert.Null (Application.Driver);
 
-			Application.Init (new MockDriver ());
+			Application.Init (new FakeDriver ());
 			Assert.NotNull (Application.Current);
 			Assert.NotNull (Application.CurrentView);
 			Assert.NotNull (Application.Top);
@@ -41,7 +41,7 @@ namespace Terminal.Gui {
 		}
 
 		[Fact]
-		public void TestNewRunState ()
+		public void RunState_Dispose_Cleans_Up ()
 		{
 			var rs = new Application.RunState (null);
 			Assert.NotNull (rs);
@@ -58,10 +58,10 @@ namespace Terminal.Gui {
 		}
 
 		[Fact]
-		public void TestBeginEnd ()
+		public void Begin_End_Cleana_Up ()
 		{
 			// Setup Mock driver
-			Application.Init (new MockDriver ());
+			Application.Init (new FakeDriver ());
 			Assert.NotNull (Application.Driver);
 
 			// Test null Toplevel
@@ -83,10 +83,10 @@ namespace Terminal.Gui {
 		}
 
 		[Fact]
-		public void TestRequestStop ()
+		public void RequestStop_Stops ()
 		{
 			// Setup Mock driver
-			Application.Init (new MockDriver ());
+			Application.Init (new FakeDriver ());
 			Assert.NotNull (Application.Driver);
 
 			var top = new Toplevel ();
@@ -109,10 +109,10 @@ namespace Terminal.Gui {
 		}
 
 		[Fact]
-		public void TestRunningFalse ()
+		public void RunningFalse_Stops ()
 		{
 			// Setup Mock driver
-			Application.Init (new MockDriver ());
+			Application.Init (new FakeDriver ());
 			Assert.NotNull (Application.Driver);
 
 			var top = new Toplevel ();
@@ -136,10 +136,10 @@ namespace Terminal.Gui {
 
 
 		[Fact]
-		public void TestKeyUp ()
+		public void KeyUp_Event ()
 		{
 			// Setup Mock driver
-			Application.Init (new MockDriver ());
+			Application.Init (new FakeDriver ());
 			Assert.NotNull (Application.Driver);
 
 			// Setup some fake kepresses (This)

+ 9 - 9
UnitTests/ConsoleDriverTests.cs

@@ -3,14 +3,14 @@ using Terminal.Gui;
 using Xunit;
 
 // Alais Console to MockConsole so we don't accidentally use Console
-using Console = Terminal.Gui.MockConsole;
+using Console = Terminal.Gui.FakeConsole;
 
 namespace Terminal.Gui {
 	public class ConsoleDriverTests {
 		[Fact]
-		public void TestInit ()
+		public void Init_Inits ()
 		{
-			var driver = new MockDriver ();
+			var driver = new FakeDriver ();
 			driver.Init (() => { });
 
 			Assert.Equal (80, Console.BufferWidth);
@@ -23,15 +23,15 @@ namespace Terminal.Gui {
 		}
 
 		[Fact]
-		public void TestEnd ()
+		public void End_Cleans_Up ()
 		{
-			var driver = new MockDriver ();
+			var driver = new FakeDriver ();
 			driver.Init (() => { });
 
-			MockConsole.ForegroundColor = ConsoleColor.Red;
+			FakeConsole.ForegroundColor = ConsoleColor.Red;
 			Assert.Equal (ConsoleColor.Red, Console.ForegroundColor);
 
-			MockConsole.BackgroundColor = ConsoleColor.Green;
+			FakeConsole.BackgroundColor = ConsoleColor.Green;
 			Assert.Equal (ConsoleColor.Green, Console.BackgroundColor);
 			driver.Move (2, 3);
 			Assert.Equal (2, Console.CursorLeft);
@@ -45,9 +45,9 @@ namespace Terminal.Gui {
 		}
 
 		[Fact]
-		public void TestSetColors ()
+		public void SetColors_Changes_Colors ()
 		{
-			var driver = new MockDriver ();
+			var driver = new FakeDriver ();
 			driver.Init (() => { });
 			Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
 			Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);

+ 0 - 129
UnitTests/DimPosTests.cs

@@ -1,129 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.IO;
-using System.Linq;
-using Terminal.Gui;
-using Xunit;
-
-// Alais Console to MockConsole so we don't accidentally use Console
-using Console = Terminal.Gui.MockConsole;
-
-namespace Terminal.Gui {
-	public class DimPosTests {
-		[Fact]
-		public void TestNew ()
-		{
-			var pos = new Pos ();
-			Assert.Equal ("Terminal.Gui.Pos", pos.ToString ());
-		}
-
-		[Fact]
-		public void TestAnchorEnd ()
-		{
-			var pos = Pos.AnchorEnd ();
-			Assert.Equal ("Pos.AnchorEnd(margin=0)", pos.ToString ());
-
-			pos = Pos.AnchorEnd (5);
-			Assert.Equal ("Pos.AnchorEnd(margin=5)", pos.ToString ());
-		}
-
-		[Fact]
-		public void TestAt ()
-		{
-			var pos = Pos.At (0);
-			Assert.Equal ("Pos.Absolute(0)", pos.ToString ());
-
-			pos = Pos.At (5);
-			Assert.Equal ("Pos.Absolute(5)", pos.ToString ());
-
-			//Assert.Throws<ArgumentException> (() => pos = Pos.At (-1));
-		}
-
-		[Fact]
-		public void TestLeft ()
-		{
-			var pos = Pos.Left (null);
-			Assert.Throws<NullReferenceException> (() => pos.ToString ());
-
-			pos = Pos.Left (new View ());
-			Assert.Equal ("Pos.View(side=x, target=View()({X=0,Y=0,Width=0,Height=0})", pos.ToString ());
-
-			pos = Pos.Left (new View (new Rect (1, 2, 3, 4)));
-			Assert.Equal ("Pos.View(side=x, target=View()({X=1,Y=2,Width=3,Height=4})", pos.ToString ());
-		}
-
-		[Fact]
-		public void TestTop ()
-		{
-			var pos = Pos.Top (null);
-			Assert.Throws<NullReferenceException> (() => pos.ToString ());
-
-			pos = Pos.Top (new View ());
-			Assert.Equal ("Pos.View(side=y, target=View()({X=0,Y=0,Width=0,Height=0})", pos.ToString ());
-
-			pos = Pos.Top (new View (new Rect (1, 2, 3, 4)));
-			Assert.Equal ("Pos.View(side=y, target=View()({X=1,Y=2,Width=3,Height=4})", pos.ToString ());
-		}
-
-		[Fact]
-		public void TestRight ()
-		{
-			var pos = Pos.Right (null);
-			Assert.Throws<NullReferenceException> (() => pos.ToString ());
-
-			pos = Pos.Right (new View ());
-			Assert.Equal ("Pos.View(side=right, target=View()({X=0,Y=0,Width=0,Height=0})", pos.ToString ());
-
-			pos = Pos.Right (new View (new Rect (1, 2, 3, 4)));
-			Assert.Equal ("Pos.View(side=right, target=View()({X=1,Y=2,Width=3,Height=4})", pos.ToString ());
-		}
-
-		[Fact]
-		public void TestBottom ()
-		{
-			var pos = Pos.Bottom (null);
-			Assert.Throws<NullReferenceException> (() => pos.ToString ());
-
-			pos = Pos.Bottom (new View ());
-			Assert.Equal ("Pos.View(side=bottom, target=View()({X=0,Y=0,Width=0,Height=0})", pos.ToString ());
-
-			pos = Pos.Bottom (new View (new Rect (1, 2, 3, 4)));
-			Assert.Equal ("Pos.View(side=bottom, target=View()({X=1,Y=2,Width=3,Height=4})", pos.ToString ());
-
-			//Assert.Throws<ArgumentException> (() => pos = Pos.Bottom (new View (new Rect (0, 0, -3, -4))));
-
-		}
-
-		[Fact]
-		public void TestCenter ()
-		{
-			var pos = Pos.Center ();
-			Assert.Equal ("Pos.Center", pos.ToString ());
-		}
-
-		[Fact]
-		public void TestPercent ()
-		{
-			System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo ("en-US");
-
-			var pos = Pos.Percent (0);
-			Assert.Equal ("Pos.Factor(0)", pos.ToString ());
-
-			pos = Pos.Percent (0.5F);
-			Assert.Equal ("Pos.Factor(0.005)", pos.ToString ());
-
-			pos = Pos.Percent (100);
-			Assert.Equal ("Pos.Factor(1)", pos.ToString ());
-
-			Assert.Throws<ArgumentException> (() => pos = Pos.Percent (-1));
-			Assert.Throws<ArgumentException> (() => pos = Pos.Percent (101));
-			Assert.Throws<ArgumentException> (() => pos = Pos.Percent (100.0001F));
-			Assert.Throws<ArgumentException> (() => pos = Pos.Percent (1000001));
-		}
-
-		// TODO: Test operators
-
-		// TODO: Test Dim
-	}
-}

+ 125 - 0
UnitTests/DimTests.cs

@@ -0,0 +1,125 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
+using Terminal.Gui;
+using Xunit;
+
+// Alais Console to MockConsole so we don't accidentally use Console
+using Console = Terminal.Gui.FakeConsole;
+
+namespace Terminal.Gui {
+	public class DimTests {
+		[Fact]
+		public void New_Works ()
+		{
+			var dim = new Dim ();
+			Assert.Equal ("Terminal.Gui.Dim", dim.ToString ());
+		}
+
+		[Fact]
+		public void Sized_SetsValue ()
+		{
+			var dim = Dim.Sized (0);
+			Assert.Equal ("Dim.Absolute(0)", dim.ToString ());
+
+			int testVal = 5;
+			dim = Dim.Sized (testVal);
+			Assert.Equal ($"Dim.Absolute({testVal})", dim.ToString ());
+		}
+
+		// TODO: Other Dim.Sized tests (e.g. Equal?)
+
+		[Fact]
+		public void Width_SetsValue ()
+		{
+			var dim = Dim.Width (null);
+			Assert.Throws<NullReferenceException> (() => dim.ToString ());
+
+			var testVal = Rect.Empty;
+			testVal = Rect.Empty;
+			dim = Dim.Width (new View (testVal));
+			Assert.Equal ($"DimView(side=Width, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
+
+			testVal = new Rect (1, 2, 3, 4);
+			dim = Dim.Width (new View (testVal));
+			Assert.Equal ($"DimView(side=Width, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
+		}
+
+		// TODO: Other Dim.Width tests (e.g. Equal?)
+
+		[Fact]
+		public void Height_SetsValue ()
+		{
+			var dim = Dim.Height (null);
+			Assert.Throws<NullReferenceException> (() => dim.ToString ());
+
+			var testVal = Rect.Empty;
+			testVal = Rect.Empty;
+			dim = Dim.Height (new View (testVal));
+			Assert.Equal ($"DimView(side=Height, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
+
+			testVal = new Rect (1, 2, 3, 4);
+			dim = Dim.Height (new View (testVal));
+			Assert.Equal ($"DimView(side=Height, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", dim.ToString ());
+		}
+
+		// TODO: Other Dim.Height tests (e.g. Equal?)
+
+		[Fact]
+		public void Fill_SetsValue ()
+		{
+			var testMargin = 0;
+			var dim = Dim.Fill ();
+			Assert.Equal ($"Dim.Fill(margin={testMargin})", dim.ToString());
+
+			testMargin = 0;
+			dim = Dim.Fill (testMargin);
+			Assert.Equal ($"Dim.Fill(margin={testMargin})", dim.ToString ());
+
+			testMargin = 5;
+			dim = Dim.Fill (testMargin);
+			Assert.Equal ($"Dim.Fill(margin={testMargin})", dim.ToString ());
+		}
+
+
+		[Fact]
+		public void Fill_Equal()
+		{
+			var margin1 = 0;
+			var margin2 = 0;
+			var dim1 = Dim.Fill (margin1);
+			var dim2 = Dim.Fill (margin2);
+			Assert.Equal (dim1, dim2);
+		}
+
+		[Fact]
+		public void Percent_SetsValue ()
+		{
+			float f = 0;
+			var dim = Dim.Percent (f);
+			Assert.Equal ($"Dim.Factor({f/100:0.###})", dim.ToString ());
+			f = 0.5F;
+			dim = Dim.Percent (f);
+			Assert.Equal ($"Dim.Factor({f/100:0.###})", dim.ToString ());
+			f = 100;
+			dim = Dim.Percent (f);
+			Assert.Equal ($"Dim.Factor({f/100:0.###})", dim.ToString ());
+		}
+
+		// TODO: Other Dim.Percent tests (e.g. Equal?)
+
+		[Fact]
+		public void Percent_ThrowsOnIvalid()
+		{
+			var dim = Dim.Percent (0);
+			Assert.Throws<ArgumentException> (() => dim = Dim.Percent (-1));
+			Assert.Throws<ArgumentException> (() => dim = Dim.Percent (101));
+			Assert.Throws<ArgumentException> (() => dim = Dim.Percent (100.0001F));
+			Assert.Throws<ArgumentException> (() => dim = Dim.Percent (1000001));
+		}
+
+		// TODO: Test operators
+	}
+}

+ 192 - 0
UnitTests/PosTests.cs

@@ -0,0 +1,192 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
+using Terminal.Gui;
+using Xunit;
+
+// Alais Console to MockConsole so we don't accidentally use Console
+using Console = Terminal.Gui.FakeConsole;
+
+namespace Terminal.Gui {
+	public class PosTests {
+		[Fact]
+		public void New_Works ()
+		{
+			var pos = new Pos ();
+			Assert.Equal ("Terminal.Gui.Pos", pos.ToString ());
+		}
+
+		[Fact]
+		public void AnchorEnd_SetsValue ()
+		{
+			var n = 0;
+			var pos = Pos.AnchorEnd ();
+			Assert.Equal ($"Pos.AnchorEnd(margin={n})", pos.ToString ());
+
+			n = 5;
+			pos = Pos.AnchorEnd (n);
+			Assert.Equal ($"Pos.AnchorEnd(margin={n})", pos.ToString ());
+		}
+
+		[Fact]
+		public void AnchorEnd_Equal ()
+		{
+			var n1 = 0;
+			var n2 = 0;
+
+			var pos1 = Pos.AnchorEnd (n1);
+			var pos2 = Pos.AnchorEnd (n2);
+			Assert.Equal (pos1, pos2);
+
+			// Test inequality
+			n2 = 5;
+			pos2 = Pos.AnchorEnd (n2);
+			Assert.NotEqual (pos1, pos2);
+		}
+
+		[Fact]
+		public void At_SetsValue ()
+		{
+			var pos = Pos.At (0);
+			Assert.Equal ("Pos.Absolute(0)", pos.ToString ());
+
+			pos = Pos.At (5);
+			Assert.Equal ("Pos.Absolute(5)", pos.ToString ());
+
+			//Assert.Throws<ArgumentException> (() => pos = Pos.At (-1));
+		}
+
+		[Fact]
+		public void At_Equal ()
+		{
+			var n1 = 0;
+			var n2 = 0;
+
+			var pos1 = Pos.At (n1);
+			var pos2 = Pos.At (n2);
+			// BUGBUG: Pos should implement equality and this should change to Equal
+			Assert.NotEqual (pos1, pos2);
+		}
+
+		[Fact]
+		public void Left_SetsValue ()
+		{
+			var pos = Pos.Left (null);
+			Assert.Throws<NullReferenceException> (() => pos.ToString ());
+
+			var testVal = Rect.Empty;
+			pos = Pos.Left (new View ());
+			Assert.Equal ($"Pos.View(side=x, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+
+			pos = Pos.Left (new View (testVal));
+			Assert.Equal ($"Pos.View(side=x, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+
+			testVal = new Rect (1, 2, 3, 4);
+			pos = Pos.Left (new View (testVal));
+			Assert.Equal ($"Pos.View(side=x, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+		}
+
+		// TODO: Test Left, Top, Right bottom Equal
+
+		[Fact]
+		public void Top_SetsValue ()
+		{
+			var pos = Pos.Top (null);
+			Assert.Throws<NullReferenceException> (() => pos.ToString ());
+
+			var testVal = Rect.Empty;
+			pos = Pos.Top (new View ());
+			Assert.Equal ($"Pos.View(side=y, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+
+			testVal = new Rect (1, 2, 3, 4);
+			pos = Pos.Top (new View (testVal));
+			Assert.Equal ($"Pos.View(side=y, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+		}
+
+		[Fact]
+		public void Right_SetsValue ()
+		{
+			var pos = Pos.Right (null);
+			Assert.Throws<NullReferenceException> (() => pos.ToString ());
+
+			var testVal = Rect.Empty;
+			pos = Pos.Right (new View ());
+			Assert.Equal ($"Pos.View(side=right, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+
+			testVal = Rect.Empty;
+			pos = Pos.Right (new View (testVal));
+			Assert.Equal ($"Pos.View(side=right, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+
+			testVal = new Rect (1, 2, 3, 4);
+			pos = Pos.Right (new View (testVal));
+			Assert.Equal ($"Pos.View(side=right, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+		}
+
+		[Fact]
+		public void Bottom_SetsValue ()
+		{
+			var pos = Pos.Bottom (null);
+			Assert.Throws<NullReferenceException> (() => pos.ToString ());
+
+			var testVal = Rect.Empty;
+			pos = Pos.Bottom (new View ());
+			Assert.Equal ($"Pos.View(side=bottom, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+
+			testVal = Rect.Empty;
+			pos = Pos.Bottom (new View (testVal));
+			Assert.Equal ($"Pos.View(side=bottom, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+
+			testVal = new Rect (1, 2, 3, 4);
+			pos = Pos.Bottom (new View (testVal));
+			Assert.Equal ($"Pos.View(side=bottom, target=View()({{X={testVal.X},Y={testVal.Y},Width={testVal.Width},Height={testVal.Height}}}))", pos.ToString ());
+
+			//Assert.Throws<ArgumentException> (() => pos = Pos.Bottom (new View (new Rect (0, 0, -3, -4))));
+		}
+
+		[Fact]
+		public void Center_SetsValue ()
+		{
+			var pos = Pos.Center ();
+			Assert.Equal ("Pos.Center", pos.ToString ());
+		}
+
+		[Fact]
+		public void Percent_SetsValue ()
+		{
+			float f = 0;
+			var pos = Pos.Percent (f);
+			Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ());
+			f = 0.5F;
+			pos = Pos.Percent (f);
+			Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ());
+			f = 100;
+			pos = Pos.Percent (f);
+			Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ());
+		}
+
+		[Fact]
+		public void Percent_Equal ()
+		{
+			var n1 = 0;
+			var n2 = 0;
+			var pos1 = Pos.Percent (n1);
+			var pos2 = Pos.Percent (n2);
+			// BUGBUG: Pos.Percent should support equality 
+			Assert.NotEqual (pos1, pos2);
+		}
+
+		[Fact]
+		public void Percent_ThrowsOnIvalid ()
+		{
+			var pos = Pos.Percent (0);
+			Assert.Throws<ArgumentException> (() => pos = Pos.Percent (-1));
+			Assert.Throws<ArgumentException> (() => pos = Pos.Percent (101));
+			Assert.Throws<ArgumentException> (() => pos = Pos.Percent (100.0001F));
+			Assert.Throws<ArgumentException> (() => pos = Pos.Percent (1000001));
+		}
+
+		// TODO: Test operators
+	}
+}

+ 3 - 3
UnitTests/ResponderTests.cs

@@ -5,12 +5,12 @@ using Terminal.Gui;
 using Xunit;
 
 // Alais Console to MockConsole so we don't accidentally use Console
-using Console = Terminal.Gui.MockConsole;
+using Console = Terminal.Gui.FakeConsole;
 
 namespace Terminal.Gui {
 	public class ResponderTests {
 		[Fact]
-		public void TestNew ()
+		public void New_Initializes ()
 		{
 			var r = new Responder ();
 			Assert.NotNull (r);
@@ -20,7 +20,7 @@ namespace Terminal.Gui {
 		}
 
 		[Fact]
-		public void TestMethods ()
+		public void New_Methods_Return_False ()
 		{
 			var r = new Responder ();
 

+ 3 - 3
UnitTests/ViewTests.cs

@@ -7,12 +7,12 @@ using Terminal.Gui;
 using Xunit;
 
 // Alais Console to MockConsole so we don't accidentally use Console
-using Console = Terminal.Gui.MockConsole;
+using Console = Terminal.Gui.FakeConsole;
 
 namespace Terminal.Gui {
 	public class ViewTests {
 		[Fact]
-		public void TestNew ()
+		public void New_Initializes ()
 		{
 			// Parameterless
 			var r = new View ();
@@ -90,7 +90,7 @@ namespace Terminal.Gui {
 		}
 
 		[Fact]
-		public void TestMethods ()
+		public void New_Methods_Return_False ()
 		{
 			var r = new View ();