2024-03-15 19:13:09 +00:00
|
|
|
using Moq;
|
|
|
|
using TUI.Engine.Attributes;
|
|
|
|
using TUI.Engine.Attributes.Orientations;
|
|
|
|
using TUI.Engine.Nodes;
|
|
|
|
using TUI.Engine.Rendering;
|
|
|
|
using TUI.Engine.Rendering.Canvas;
|
|
|
|
using TUI.Engine.Tests.Stubs;
|
|
|
|
|
2024-03-16 19:39:58 +00:00
|
|
|
namespace TUI.Engine.Tests.Draw;
|
2024-03-15 19:13:09 +00:00
|
|
|
|
2024-03-16 19:39:58 +00:00
|
|
|
public class DrawResizingTests : ComponentBaseTests
|
2024-03-15 19:13:09 +00:00
|
|
|
{
|
|
|
|
private readonly TestContainer _container;
|
|
|
|
private readonly TestContainer _root;
|
2024-03-16 19:39:58 +00:00
|
|
|
private readonly ICanvas _canvas;
|
2024-03-15 19:13:09 +00:00
|
|
|
|
|
|
|
public DrawResizingTests()
|
|
|
|
{
|
|
|
|
var component = Prepare.Component();
|
|
|
|
_canvas = Mock.Of<ICanvas>(w => w.Size == new Size(20, 2));
|
|
|
|
_container = Prepare.Container(component);
|
|
|
|
_root = Prepare.Container(_container, component);
|
|
|
|
_root.SetOrientationHorizontal();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
2024-03-16 19:39:58 +00:00
|
|
|
[Trait("Category", nameof(IDrawable<INode>.Draw))]
|
2024-03-15 19:13:09 +00:00
|
|
|
public void DrawResizingFixedContainer()
|
|
|
|
{
|
|
|
|
_container.SetFixed(Orientation.Horizontal, 6);
|
|
|
|
_container.SetFixed(Orientation.Vertical, 2);
|
|
|
|
|
2024-03-16 19:39:58 +00:00
|
|
|
Craftsman(_canvas).Draw(_root, Position.Default, _canvas.Size);
|
2024-03-15 19:13:09 +00:00
|
|
|
|
|
|
|
Mock.Get(_canvas).VerifyPositionOnce(Position.Default);
|
|
|
|
Mock.Get(_canvas).VerifyPositionOnce(6, 0);
|
|
|
|
Mock.Get(_canvas).Verify(w => w.Paint("Lorem"), Times.Exactly(2));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
2024-03-16 19:39:58 +00:00
|
|
|
[Trait("Category", nameof(IDrawable<INode>.Draw))]
|
2024-03-15 19:13:09 +00:00
|
|
|
public void DrawResizingAdaptiveContainer()
|
|
|
|
{
|
|
|
|
_container.SetAdaptive(Orientation.Horizontal);
|
|
|
|
|
2024-03-16 19:39:58 +00:00
|
|
|
Craftsman(_canvas).Draw(_root, Position.Default, _canvas.Size);
|
2024-03-15 19:13:09 +00:00
|
|
|
|
|
|
|
Mock.Get(_canvas).VerifyPositionOnce(Position.Default);
|
|
|
|
Mock.Get(_canvas).VerifyPositionOnce(10, 0);
|
|
|
|
Mock.Get(_canvas).Verify(w => w.Paint("Lorem"), Times.Exactly(2));
|
|
|
|
}
|
|
|
|
}
|