mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
using Xunit.Abstractions;
|
|
|
|
namespace Terminal.Gui.LayoutTests;
|
|
|
|
public class PosFuncTests (ITestOutputHelper output)
|
|
{
|
|
private readonly ITestOutputHelper _output = output;
|
|
|
|
[Fact]
|
|
public void PosFunc_Equal ()
|
|
{
|
|
Func<int> f1 = () => 0;
|
|
Func<int> f2 = () => 0;
|
|
|
|
Pos pos1 = Pos.Func (f1);
|
|
Pos pos2 = Pos.Func (f2);
|
|
Assert.Equal (pos1, pos2);
|
|
|
|
f2 = () => 1;
|
|
pos2 = Pos.Func (f2);
|
|
Assert.NotEqual (pos1, pos2);
|
|
}
|
|
|
|
[Fact]
|
|
public void PosFunc_SetsValue ()
|
|
{
|
|
var text = "Test";
|
|
Pos pos = Pos.Func (() => text.Length);
|
|
Assert.Equal ("PosFunc(4)", pos.ToString ());
|
|
|
|
text = "New Test";
|
|
Assert.Equal ("PosFunc(8)", pos.ToString ());
|
|
|
|
text = "";
|
|
Assert.Equal ("PosFunc(0)", pos.ToString ());
|
|
}
|
|
|
|
[Fact]
|
|
public void PosFunc_Calculate_ReturnsCorrectValue ()
|
|
{
|
|
var pos = new PosFunc (() => 10);
|
|
int result = pos.Calculate (0, 100, null, Dimension.None);
|
|
Assert.Equal (10, result);
|
|
}
|
|
}
|