Files
Terminal.Gui/UnitTests/Views/FrameViewTests.cs
Tig 574ed8fec7 Fixes #2469 - Revamp file structure and namespace (#2471)
* initial commit

* All tests pass

* Updated readme

* Revert "All tests pass"

This reverts commit 94ac462350.

* Revert "initial commit"

This reverts commit 36d92cc4e5.

* Moved Terminal.Gui files around

* Nuked .Graphs namespace

* Nuked .Graphs namespace

* Nuked .Trees namespace

* Nuked .Configuration namespace

* Nuked .Configuration namespace

* All tests pass

* tweaked tests

* removed unneeded usings

* re-enabled scrollview tests

* move scrollview test to ScrollViewTests

* Moved view navigation related tests to separate cs file

* Moved view scrollbarview related tests ScrollBarTestse

* Refactored View tests into smaller files

* Refactored driver tests

* Fixed a ton of BUGBUGs
2023-04-06 10:09:21 -06:00

96 lines
2.3 KiB
C#

using Microsoft.VisualStudio.TestPlatform.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
namespace Terminal.Gui.ViewsTests {
public class FrameViewTests {
readonly ITestOutputHelper output;
public FrameViewTests (ITestOutputHelper output)
{
this.output = output;
}
[Fact]
public void Constuctors_Defaults ()
{
var fv = new FrameView ();
Assert.Equal (string.Empty, fv.Title);
Assert.Equal (string.Empty, fv.Text);
Assert.NotNull (fv.Border);
fv = new FrameView ("Test");
Assert.Equal ("Test", fv.Title);
Assert.Equal (string.Empty, fv.Text);
Assert.NotNull (fv.Border);
fv = new FrameView (new Rect (1, 2, 10, 20), "Test");
Assert.Equal ("Test", fv.Title);
Assert.Equal (string.Empty, fv.Text);
Assert.NotNull (fv.Border);
fv.BeginInit ();
fv.EndInit ();
Assert.Equal (new Rect (1, 2, 10, 20), fv.Frame);
}
[Fact, AutoInitShutdown]
public void Draw_Defaults ()
{
((FakeDriver)Application.Driver).SetBufferSize (10, 10);
var fv = new FrameView ();
Assert.Equal (string.Empty, fv.Title);
Assert.Equal (string.Empty, fv.Text);
Assert.NotNull (fv.Border);
Application.Top.Add (fv);
Application.Begin (Application.Top);
Assert.Equal (new Rect (0, 0, 0, 0), fv.Frame);
TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
fv.Height = 5;
fv.Width = 5;
Assert.Equal (new Rect (0, 0, 5, 5), fv.Frame);
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (@"
┌───┐
│ │
│ │
│ │
└───┘", output);
fv.X = 1;
fv.Y = 2;
Assert.Equal (new Rect (1, 2, 5, 5), fv.Frame);
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (@"
┌───┐
│ │
│ │
│ │
└───┘", output);
fv.X = -1;
fv.Y = -2;
Assert.Equal (new Rect (-1, -2, 5, 5), fv.Frame);
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (@"
───┘", output);
fv.X = 7;
fv.Y = 8;
Assert.Equal (new Rect (7, 8, 5, 5), fv.Frame);
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (@"
┌──
│ ", output);
}
}
}