Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions UnitTests/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,3 @@
// Since Application is a singleton we can't run tests in parallel
[assembly: CollectionBehavior (DisableTestParallelization = true)]

// This class enables test functions annotated with the [AutoInitShutdown] attribute to
// automatically call Application.Init before called and Application.Shutdown after
//
// This is necessary because a) Application is a singleton and Init/Shutdown must be called
// as a pair, and b) all unit test functions should be atomic.
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class AutoInitShutdownAttribute : Xunit.Sdk.BeforeAfterTestAttribute {

static bool _init = false;
public override void Before (MethodInfo methodUnderTest)
{
if (_init) {
throw new InvalidOperationException ("After did not run.");
}

Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
_init = true;
}

public override void After (MethodInfo methodUnderTest)
{
Application.Shutdown ();
_init = false;
}
}
26 changes: 13 additions & 13 deletions UnitTests/ButtonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Constructors_Defaults ()
var expected = @"
[ ]
";
GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);

Application.End (rs);
btn = new Button ("ARGS", true) { Text = "Test" };
Expand All @@ -47,7 +47,7 @@ [ ]
expected = @"
[◦ Test ◦]
";
GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);

Application.End (rs);
btn = new Button (3, 4, "Test", true);
Expand All @@ -65,7 +65,7 @@ [ ]
expected = @"
[◦ Test ◦]
";
GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);

Application.End (rs);
}
Expand Down Expand Up @@ -235,7 +235,7 @@ public void Update_Only_On_Or_After_Initialize ()
└────────────────────────────┘
";

var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);
}

Expand Down Expand Up @@ -273,7 +273,7 @@ public void Update_Parameterless_Only_On_Or_After_Initialize ()
└────────────────────────────┘
";

var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);
}

Expand Down Expand Up @@ -310,7 +310,7 @@ public void AutoSize_Stays_True_With_EmptyText ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}

[Fact, AutoInitShutdown]
Expand Down Expand Up @@ -342,7 +342,7 @@ public void AutoSize_Stays_True_Center ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);

Assert.True (btn.AutoSize);
btn.Text = "Say Hello 你 changed";
Expand All @@ -356,7 +356,7 @@ public void AutoSize_Stays_True_Center ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}

[Fact, AutoInitShutdown]
Expand Down Expand Up @@ -389,7 +389,7 @@ public void AutoSize_Stays_True_AnchorEnd ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);

Assert.True (btn.AutoSize);
btn.Text = "Say Hello 你 changed";
Expand All @@ -403,7 +403,7 @@ public void AutoSize_Stays_True_AnchorEnd ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}

[Fact, AutoInitShutdown]
Expand Down Expand Up @@ -520,7 +520,7 @@ public void AutoSize_False_With_Fixed_Width ()
└────────────────────────────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}

[Fact, AutoInitShutdown]
Expand Down Expand Up @@ -550,7 +550,7 @@ public void Pos_Center_Layout_AutoSize_True ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}

[Fact, AutoInitShutdown]
Expand Down Expand Up @@ -582,7 +582,7 @@ public void Pos_Center_Layout_AutoSize_False ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}
}
}
38 changes: 19 additions & 19 deletions UnitTests/CheckboxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void KeyBindings_Command ()
√ Test
";

var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 6, 1), pos);
}

Expand Down Expand Up @@ -123,7 +123,7 @@ public void AutoSize_StaysVisible ()
";

// Positive test
var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);

// Also Positive test
Expand All @@ -139,7 +139,7 @@ public void AutoSize_StaysVisible ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);

checkBox.Checked = true;
Expand All @@ -153,7 +153,7 @@ public void AutoSize_StaysVisible ()
└────────────────────────────┘
";

pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);

checkBox.AutoSize = false;
Expand All @@ -169,7 +169,7 @@ public void AutoSize_StaysVisible ()
└────────────────────────────┘
";

pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);

checkBox.Width = 19;
Expand All @@ -186,7 +186,7 @@ public void AutoSize_StaysVisible ()
└────────────────────────────┘
";

pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);

checkBox.AutoSize = true;
Expand All @@ -200,7 +200,7 @@ public void AutoSize_StaysVisible ()
└────────────────────────────┘
";

pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);
}

Expand Down Expand Up @@ -240,7 +240,7 @@ public void TextAlignment_Left ()
└────────────────────────────┘
";

var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);

checkBox.Checked = true;
Expand All @@ -253,7 +253,7 @@ public void TextAlignment_Left ()
└────────────────────────────┘
";

pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);
}

Expand Down Expand Up @@ -294,7 +294,7 @@ public void TextAlignment_Centered ()
└────────────────────────────┘
";

var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);

checkBox.Checked = true;
Expand All @@ -307,7 +307,7 @@ public void TextAlignment_Centered ()
└────────────────────────────┘
";

pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);
}

Expand Down Expand Up @@ -364,7 +364,7 @@ public void TextAlignment_Justified ()
└────────────────────────────┘
";

var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 6), pos);

checkBox1.Checked = true;
Expand All @@ -383,7 +383,7 @@ public void TextAlignment_Justified ()
└────────────────────────────┘
";

pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 6), pos);
}

Expand Down Expand Up @@ -424,7 +424,7 @@ public void TextAlignment_Right ()
└────────────────────────────┘
";

var pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);

checkBox.Checked = true;
Expand All @@ -437,7 +437,7 @@ public void TextAlignment_Right ()
└────────────────────────────┘
";

pos = GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new Rect (0, 0, 30, 5), pos);
}

Expand Down Expand Up @@ -470,7 +470,7 @@ public void AutoSize_Stays_True_AnchorEnd_Without_HotKeySpecifier ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);

Assert.True (checkBox.AutoSize);
checkBox.Text = "Check this out 你 changed";
Expand All @@ -484,7 +484,7 @@ public void AutoSize_Stays_True_AnchorEnd_Without_HotKeySpecifier ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}

[Fact, AutoInitShutdown]
Expand Down Expand Up @@ -516,7 +516,7 @@ public void AutoSize_Stays_True_AnchorEnd_With_HotKeySpecifier ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);

Assert.True (checkBox.AutoSize);
checkBox.Text = "Check this out 你 changed";
Expand All @@ -530,7 +530,7 @@ public void AutoSize_Stays_True_AnchorEnd_With_HotKeySpecifier ()
└────────────────────────────┘
";

GraphViewTests.AssertDriverContentsWithFrameAre (expected, output);
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}
}
}
Loading