mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Tweaks to make code more clear
This commit is contained in:
@@ -85,7 +85,34 @@ namespace Terminal.Gui.DriverTests {
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Make_SetsNotInitialized_IfNotInit ()
|
||||
public void Implicit_Assign_NoDriver ()
|
||||
{
|
||||
|
||||
var attr = new Attribute ();
|
||||
|
||||
var fg = new Color ();
|
||||
fg = Color.Red;
|
||||
|
||||
var bg = new Color ();
|
||||
bg = Color.Blue;
|
||||
|
||||
// Test conversion to int
|
||||
attr = new Attribute (fg, bg);
|
||||
int value_implicit = (int)attr.Value;
|
||||
Assert.False (attr.Initialized);
|
||||
|
||||
Assert.Equal (-1, value_implicit);
|
||||
Assert.False (attr.Initialized);
|
||||
|
||||
// Test conversion from int
|
||||
attr = -1;
|
||||
Assert.Equal (-1, attr.Value);
|
||||
Assert.False (attr.Initialized);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Make_SetsNotInitialized_NoDriver ()
|
||||
{
|
||||
var fg = new Color ();
|
||||
fg = Color.Red;
|
||||
@@ -95,7 +122,7 @@ namespace Terminal.Gui.DriverTests {
|
||||
|
||||
var a = Attribute.Make (fg, bg);
|
||||
|
||||
Assert.False (a.IsInitialized);
|
||||
Assert.False (a.Initialized);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -111,8 +138,8 @@ namespace Terminal.Gui.DriverTests {
|
||||
var bg = new Color ();
|
||||
bg = Color.Blue;
|
||||
|
||||
var attr = Attribute.Make (fg, bg);
|
||||
Assert.True (attr.IsInitialized);
|
||||
var attr = Attribute.Make (fg, bg);
|
||||
Assert.True (attr.Initialized);
|
||||
Assert.Equal (fg, attr.Foreground);
|
||||
Assert.Equal (bg, attr.Background);
|
||||
|
||||
@@ -121,7 +148,23 @@ namespace Terminal.Gui.DriverTests {
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Get_Asserts_IfNotInit ()
|
||||
public void Make_Creates_NoDriver ()
|
||||
{
|
||||
|
||||
var fg = new Color ();
|
||||
fg = Color.Red;
|
||||
|
||||
var bg = new Color ();
|
||||
bg = Color.Blue;
|
||||
|
||||
var attr = Attribute.Make (fg, bg);
|
||||
Assert.False (attr.Initialized);
|
||||
Assert.Equal (fg, attr.Foreground);
|
||||
Assert.Equal (bg, attr.Background);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Get_Asserts_NoDriver ()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException> (() => Attribute.Get ());
|
||||
}
|
||||
@@ -165,5 +208,24 @@ namespace Terminal.Gui.DriverTests {
|
||||
Assert.Equal (Color.Red, fg);
|
||||
Assert.Equal (Color.Green, bg);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsValid_Tests ()
|
||||
{
|
||||
var attr = new Attribute ();
|
||||
Assert.True (attr.HasValidColors);
|
||||
|
||||
attr = new Attribute (Color.Red, Color.Green);
|
||||
Assert.True (attr.HasValidColors);
|
||||
|
||||
attr = new Attribute (Color.Red, Color.Invalid);
|
||||
Assert.False (attr.HasValidColors);
|
||||
|
||||
attr = new Attribute (Color.Invalid, Color.Green);
|
||||
Assert.False (attr.HasValidColors);
|
||||
|
||||
attr = new Attribute (Color.Invalid, Color.Invalid);
|
||||
Assert.False (attr.HasValidColors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user