mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Added more unit tests as requested in https://github.com/migueldeicaza/gui.cs/pull/1249#issuecomment-827787161
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Terminal.Gui.Views {
|
||||
public class TextViewTests {
|
||||
private static TextView _textView;
|
||||
readonly ITestOutputHelper output;
|
||||
|
||||
public TextViewTests (ITestOutputHelper output)
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
// This class enables test functions annotated with the [InitShutdown] attribute
|
||||
// to have a function called before the test function is called and after.
|
||||
@@ -1872,5 +1879,54 @@ namespace Terminal.Gui.Views {
|
||||
var tv = new TextView ();
|
||||
Assert.Throws<ArgumentNullException> (() => tv.CloseFile ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WordWrap_Gets_Sets ()
|
||||
{
|
||||
var tv = new TextView () { WordWrap = true };
|
||||
Assert.True (tv.WordWrap);
|
||||
tv.WordWrap = false;
|
||||
Assert.False (tv.WordWrap);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WordWrap_True_Text_Always_Returns_Unwrapped ()
|
||||
{
|
||||
var text = "This is the first line.\nThis is the second line.\n";
|
||||
var tv = new TextView () { Width = 10 };
|
||||
tv.Text = text;
|
||||
Assert.Equal ($"This is the first line.{Environment.NewLine}This is the second line.{Environment.NewLine}", tv.Text);
|
||||
tv.WordWrap = true;
|
||||
Assert.Equal ($"This is the first line.{Environment.NewLine}This is the second line.{Environment.NewLine}", tv.Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[InitShutdown]
|
||||
public void WordWrap_WrapModel_Output ()
|
||||
{
|
||||
// 0123456789
|
||||
var text = "This is the first line.\nThis is the second line.\n";
|
||||
var tv = new TextView () { Width = 10, Height = 10 };
|
||||
tv.Text = text;
|
||||
Assert.Equal ($"This is the first line.{Environment.NewLine}This is the second line.{Environment.NewLine}", tv.Text);
|
||||
tv.WordWrap = true;
|
||||
|
||||
Application.Top.Add (tv);
|
||||
|
||||
tv.Redraw (tv.Bounds);
|
||||
|
||||
string expected = @"
|
||||
This is
|
||||
the
|
||||
first
|
||||
line.
|
||||
This is
|
||||
the
|
||||
second
|
||||
line.
|
||||
";
|
||||
|
||||
GraphViewTests.AssertDriverContentsAre (expected, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user