🧪 Change tests.

This commit is contained in:
Kolosov Alexandr 2024-03-10 01:09:28 +05:00
parent f32c34ff9e
commit e15e42dbe8
21 changed files with 167 additions and 159 deletions

View File

@ -13,15 +13,19 @@ public class HeaderContainer : ContainerBase, IContainer
{
var versionHints = new VersionHints();
versionHints.SetPadding(Indentation.Default);
versionHints.SetAlignment(Horizontal.Left);
var tagsHints = new TagHints();
tagsHints.SetPadding(Indentation.Default);
tagsHints.SetAlignment(Horizontal.Left);
var appTypeHints = new AppTypeHints();
appTypeHints.SetPadding(Indentation.Default);
appTypeHints.SetAlignment(Horizontal.Left);
var hotkeysHints = new HotkeysHint();
hotkeysHints.SetPadding(Indentation.Default);
hotkeysHints.SetAlignment(Horizontal.Left);
var logo = new Logo();
logo.SetAlignment(Horizontal.Right);

View File

@ -4,7 +4,7 @@ namespace TUI.Engine.Nodes.Attributes.Paddings;
public interface IPaddingable
{
Padding? Padding { get; }
Padding Padding { get; }
void SetPadding(Level level);
void SetPaddingLeft(Level level);

View File

@ -9,6 +9,6 @@ public interface IResizable
Resizing ResizingVertical { get; }
void SetAdaptive(Orientation orientation);
void SetHug(Orientation orientation);
void SetFixed(Orientation orientation, int value);
Size GetFixedSize();
}

View File

@ -3,6 +3,5 @@ namespace TUI.Engine.Nodes.Attributes.Resizing;
public enum Resizing
{
Adaptive,
Fixed,
Hug,
Fixed
}

View File

@ -14,7 +14,7 @@ public abstract class ComponentBase : NodeBase, IComponent
public abstract Sketch DrawComponent();
public Sketch Draw()
public Sketch MakeSketch()
{
var sketch = DrawComponent();
_sketchSize = sketch.GetSize();

View File

@ -5,5 +5,5 @@ namespace TUI.Engine.Nodes.Components;
public interface IComponent : INode, IAlignable, IPaddingable
{
Sketch Draw();
Sketch MakeSketch();
}

View File

@ -10,7 +10,7 @@ public sealed class Sketch : IEnumerable<string>
public IEnumerator<string> GetEnumerator() => ContentRows.GetEnumerator();
public IEnumerable<string> Rows(Size maxSize) =>
public IEnumerable<string> Crop(Size maxSize) =>
ContentRows.Where(row => maxSize.Width >= row.GetWidth()).Take(maxSize.Height).ToArray();
public Size GetSize()

View File

@ -1,3 +1,4 @@
using TUI.Engine.Nodes.Attributes;
using TUI.Engine.Nodes.Attributes.Orientations;
namespace TUI.Engine.Nodes.Containers;
@ -6,5 +7,10 @@ public abstract class ContainerBase : NodeBase, IContainer
{
public Orientation Orientation => Orientation.Horizontal;
public Size GetSketchSize()
{
throw new NotImplementedException();
}
public abstract Nodes GetNodes();
}

View File

@ -8,55 +8,17 @@ namespace TUI.Engine.Nodes.Containers;
public static class ContainerExtension
{
public static Size GetSize(this IContainer container, Resizing resizing)
{
int width = resizing switch
{
// Resizing.Fixed => _fixedWeight,
// Resizing.Hug => GetAllowableSize().Width,
// Resizing.Adaptive => GetAllowableSize().Width,
_ => 0
};
int height = resizing switch
{
// Resizing.Fixed => _fixedHeight,
// Resizing.Hug => GetAllowableSize().Height,
// Resizing.Adaptive => GetAllowableSize().Height,
_ => 0
};
return new Size(width, height);
}
public static Position GetNextNodePosition(this IContainer container, Orientation orientation, Size allowableSize,
Position containerPosition)
{
var nodeSize = container.GetSize(allowableSize);
return GetNextNodePosition(orientation, nodeSize, containerPosition);
}
private static Position GetNextNodePosition(Orientation orientation, Size nodeSize, Position nodePosition) =>
orientation switch
{
Orientation.Horizontal => nodePosition with
{
Left = nodePosition.Left + nodeSize.Width
},
Orientation.Vertical => nodePosition with
{
Top = nodePosition.Top + nodeSize.Height
},
_ => throw new ArgumentOutOfRangeException()
};
public static Size GetSize(this IContainer container, Size allowableSize)
{
var nodeCount = container.GetNodes().Count;
var width = container.Orientation == Orientation.Horizontal
var width = container.ResizingHorizontal switch
{
Resizing.Adaptive => container.Orientation == Orientation.Horizontal
? allowableSize.Width / nodeCount
: allowableSize.Width;
: allowableSize.Width,
Resizing.Fixed => container.GetFixedSize().Width,
_ => throw new ArgumentOutOfRangeException()
};
var height = container.Orientation == Orientation.Vertical
? allowableSize.Height / nodeCount
: allowableSize.Height;
@ -67,33 +29,32 @@ public static class ContainerExtension
public static class ComponentExtensions
{
public static Position GetPosition(this IComponent component, Position sketchPosition, Size allowableSize,
Size actualSize)
public static Position CorrectPosition(this IComponent component, Position pencil, Size maxSize, Size sketchSize)
{
var left = sketchPosition.Left + (int)(component.Padding?.Left ?? 0) +
CompensationLeft(component.Alignment.Horizontal, allowableSize, actualSize);
var top = sketchPosition.Top + (int)(component.Padding?.Top ?? 0) +
CompensationTop(component.Alignment.Vertical, allowableSize, actualSize);
var padding = component.Padding;
var alignment = component.Alignment;
var alignmentCompensationLeft = GetAlignmentCompensationLeft(alignment.Horizontal, maxSize, sketchSize);
var alignmentCompensationTop = GetAlignmentCompensationTop(alignment.Vertical, maxSize, sketchSize);
var left = pencil.Left + (int)padding.Left + alignmentCompensationLeft;
var top = pencil.Top + (int)padding.Top + alignmentCompensationTop;
return new Position(left, top);
}
private static int CompensationLeft(Horizontal componentHorizontal, Size defaultSize,
Size realSize) =>
componentHorizontal switch
private static int GetAlignmentCompensationLeft(Horizontal alignment, Size maxSize, Size sketchSize) =>
alignment switch
{
Horizontal.Left => 0,
Horizontal.Center => (defaultSize.Width - realSize.Width) / 2,
Horizontal.Right => defaultSize.Width - realSize.Width,
Horizontal.Center => (maxSize.Width - sketchSize.Width) / 2,
Horizontal.Right => maxSize.Width - sketchSize.Width,
_ => 0
};
private static int CompensationTop(Vertical componentVertical, Size defaultSize, Size realSize)
=>
componentVertical switch
private static int GetAlignmentCompensationTop(Vertical alignment, Size maxSize, Size sketchSize) =>
alignment switch
{
Vertical.Top => 0,
Vertical.Center => (defaultSize.Height - realSize.Height) / 2,
Vertical.Bottom => defaultSize.Height - realSize.Height,
Vertical.Center => (maxSize.Height - sketchSize.Height) / 2,
Vertical.Bottom => maxSize.Height - sketchSize.Height,
_ => 0
};
}

View File

@ -1,9 +1,10 @@
using TUI.Engine.Nodes.Attributes;
using TUI.Engine.Nodes.Attributes.Orientations;
namespace TUI.Engine.Nodes.Containers;
public interface IContainer : INode,
IWithOrientation
public interface IContainer : INode, IWithOrientation
{
public Nodes GetNodes();
Size GetSketchSize();
Nodes GetNodes();
}

View File

@ -1,3 +1,4 @@
using TUI.Engine.Nodes.Attributes;
using TUI.Engine.Nodes.Attributes.Orientations;
using TUI.Engine.Nodes.Attributes.Resizing;
@ -8,10 +9,12 @@ public abstract class NodeBase : INode
private int _fixedWidth;
private int _fixedHeight;
public Size GetFixedSize() => new(_fixedWidth, _fixedHeight);
#region Resizing
public Resizing ResizingHorizontal { get; private set; } = Resizing.Adaptive;
public Resizing ResizingVertical { get; private set; } = Resizing.Hug;
public Resizing ResizingVertical { get; private set; } = Resizing.Adaptive;
public void SetAdaptive(Orientation orientation)
{
@ -28,21 +31,6 @@ public abstract class NodeBase : INode
}
}
public void SetHug(Orientation orientation)
{
switch (orientation)
{
case Orientation.Horizontal:
ResizingHorizontal = Resizing.Hug;
break;
case Orientation.Vertical:
ResizingVertical = Resizing.Hug;
break;
default:
throw new ArgumentOutOfRangeException(nameof(orientation), orientation, null);
}
}
public void SetFixed(Orientation orientation, int value)
{
switch (orientation)

View File

@ -14,23 +14,23 @@ public sealed class ComponentCraftsman : CraftsmanBase, IDrawable<IComponent>
_canvas = canvas;
}
public Size Draw(IComponent component, Position sketchPosition, Size allowableSize)
public Size Draw(IComponent component, Position pencil, Size maxSize)
{
var sketch = component.Draw();
var actualSize = sketch.GetSize();
var maxSize = _canvas.GetSize() - sketchPosition;
var pencilPosition = component.GetPosition(sketchPosition, allowableSize, actualSize);
var sketch = component.MakeSketch();
var sketchSize = sketch.GetSize();
foreach (var row in sketch.Rows(maxSize))
var correctedPencil = component.CorrectPosition(pencil, maxSize, sketchSize);
Debug(correctedPencil, pencil, maxSize);
foreach (var line in sketch.Crop(maxSize))
{
_canvas.SetPencil(pencilPosition.Left, pencilPosition.Top);
_canvas.Paint(row);
_canvas.SetPencil(correctedPencil.Left, correctedPencil.Top);
_canvas.Paint(line);
pencilPosition = pencilPosition with { Top = pencilPosition.Top + 1 };
correctedPencil = correctedPencil with { Top = correctedPencil.Top + 1 };
}
Debug(pencilPosition, sketchPosition, allowableSize);
return actualSize;
return sketchSize;
}
}

View File

@ -1,6 +1,7 @@
using TUI.Engine.Nodes;
using TUI.Engine.Nodes.Attributes;
using TUI.Engine.Nodes.Attributes.Orientations;
using TUI.Engine.Nodes.Attributes.Resizing;
using TUI.Engine.Nodes.Components;
using TUI.Engine.Nodes.Containers;
@ -15,52 +16,64 @@ public sealed class ContainerCraftsman : CraftsmanBase, IDrawable<IContainer>
_componentCraftsman = componentCraftsman;
}
public Size Draw(IContainer container, Position sketchPosition, Size allowableSize)
public Size Draw(IContainer container, Position pencil, Size maxSize)
{
var sketchSize = container.GetSize(allowableSize);
var controlNumber = 0;
var nextNodePosition = pencil;
var nodes = container.GetNodes();
var sketchSize = container.GetSize(maxSize);
Debug(nextNodePosition, nextNodePosition, maxSize);
while (controlNumber < nodes.Count)
{
var node = nodes[controlNumber];
sketchPosition = DrawNode(node, container.Orientation, sketchPosition, sketchSize);
nextNodePosition = DrawNode(node, container, nextNodePosition, sketchSize);
controlNumber++;
}
Debug(sketchPosition, sketchPosition, allowableSize);
return sketchSize;
}
private Position DrawNode(INode node, Orientation orientation, Position sketchPosition, Size sketchSize)
private Position DrawNode(INode node, IContainer container, Position nodePosition, Size maxSize)
{
switch (node)
{
case IContainer childContainer:
Draw(childContainer, sketchPosition, sketchSize);
return GetNextNodePosition(orientation, sketchSize, sketchPosition);
var containerSize = Draw(childContainer, nodePosition, maxSize);
return GetNextNodePosition(container, containerSize, nodePosition);
case IComponent childComponent:
var componentSize = _componentCraftsman.Draw(childComponent, sketchPosition, sketchSize);
return GetNextNodePosition(orientation, sketchSize, sketchPosition, componentSize);
var componentSize = _componentCraftsman.Draw(childComponent, nodePosition, maxSize);
return GetNextNodePosition(container, maxSize, nodePosition, componentSize);
default:
throw new InvalidCastException();
}
}
private static Position GetNextNodePosition(
Orientation orientation,
IContainer container,
Size defaultSize,
Position position,
Size? componentSize = null)
{
switch (orientation)
switch (container.Orientation)
{
case Orientation.Horizontal:
var componentWidth = componentSize?.Width.Max(defaultSize.Width) ?? defaultSize.Width;
var componentWidth = container.ResizingHorizontal switch
{
Resizing.Adaptive => defaultSize.Width,
Resizing.Fixed => componentSize?.Width.Max(container.GetFixedSize().Width) ??
container.GetFixedSize().Width,
_ => 0
};
return position with { Left = position.Left + componentWidth };
case Orientation.Vertical:
var componentHeight = componentSize?.Height.Max(defaultSize.Height) ?? defaultSize.Height;
var componentHeight = container.ResizingVertical switch
{
Resizing.Adaptive => defaultSize.Height,
Resizing.Fixed => componentSize?.Height.Max(container.GetFixedSize().Height) ??
container.GetFixedSize().Height,
_ => 0
};
return position with { Top = position.Top + componentHeight };
default:
throw new InvalidCastException();

View File

@ -5,5 +5,5 @@ namespace TUI.Engine.Rendering;
public interface IDrawable<in TItem> where TItem : INode
{
Size Draw(TItem item, Position sketchPosition, Size allowableSize);
Size Draw(TItem item, Position pencil, Size maxSize);
}

View File

@ -2,5 +2,5 @@ namespace TUI.Engine.Rendering;
public static class IntegerExtension
{
public static int Max(this int value, int maxValue) => maxValue <= value ? value : maxValue;
public static int Max(this int value, int maxValue) => value <= maxValue ? value : maxValue;
}

View File

@ -5,6 +5,9 @@ using TUI.Engine.Nodes.Containers;
namespace TUI.Engine.Rendering;
/// <summary>
/// 🍀
/// </summary>
public sealed class NodeCraftsman : IDrawable<INode>
{
private readonly IDrawable<IComponent> _componentCraftsman;
@ -18,11 +21,11 @@ public sealed class NodeCraftsman : IDrawable<INode>
_containerCraftsman = containerCraftsman;
}
public Size Draw(INode node, Position sketchPosition, Size allowableSize) =>
public Size Draw(INode node, Position pencil, Size maxSize) =>
node switch
{
IContainer container => _containerCraftsman.Draw(container, sketchPosition, allowableSize),
IComponent component => _componentCraftsman.Draw(component, sketchPosition, allowableSize),
IContainer container => _containerCraftsman.Draw(container, pencil, maxSize),
IComponent component => _componentCraftsman.Draw(component, pencil, maxSize),
_ => throw new InvalidCastException("Unknown node type.")
};
}

View File

@ -1,9 +1,9 @@
using Moq;
using TUI.Engine.Nodes;
using TUI.Engine.Nodes.Attributes;
using TUI.Engine.Nodes.Attributes.Alignments;
using TUI.Engine.Nodes.Attributes.Orientations;
using TUI.Engine.Nodes.Attributes.Resizing;
using TUI.Engine.Nodes.Components;
using TUI.Engine.Nodes.Containers;
using TUI.Engine.Rendering;
@ -11,25 +11,22 @@ namespace Widgets.Tests;
public class NodeCraftsmanTests
{
private readonly IComponent _component;
private readonly TestComponent _component;
public NodeCraftsmanTests()
{
_component = Mock.Of<IComponent>(c =>
c.Draw() == new Sketch("Lorem") &&
c.Alignment == new Alignment(Horizontal.Left, Vertical.Top));
_component = new TestComponent();
_component.SetAlignment(Horizontal.Left);
_component.SetAlignment(Vertical.Top);
}
[Fact]
public void DrawSimple()
{
var canvas = Mock.Of<ICanvas>(w => w.Width == 9 && w.Height == 1);
var nodes = new Nodes { _component };
var root = Mock.Of<IContainer>(r => r.GetNodes() == nodes);
var componentCraftsman = new ComponentCraftsman(canvas);
var containerCraftsman = new ContainerCraftsman(componentCraftsman);
new NodeCraftsman(componentCraftsman, containerCraftsman).Draw(root, Position.Default, canvas.GetSize());
componentCraftsman.Draw(_component, Position.Default, canvas.GetSize());
Mock.Get(canvas).Verify(w => w.SetPencil(0, 0), Times.Once());
Mock.Get(canvas).Verify(w => w.Paint("Lorem"), Times.Once());
@ -47,14 +44,12 @@ public class NodeCraftsmanTests
int expectedPosition)
{
var canvas = Mock.Of<ICanvas>(w => w.Width == canvasSize && w.Height == canvasSize);
var component = Mock.Of<IComponent>(c => c.Draw() == new Sketch(content) &&
c.Alignment == new Alignment(alignment, Vertical.Top));
var nodes = new Nodes { component };
var root = Mock.Of<IContainer>(r => r.GetNodes() == nodes);
_component.SetContent(content);
_component.SetAlignment(Vertical.Top);
_component.SetAlignment(alignment);
var componentCraftsman = new ComponentCraftsman(canvas);
var containerCraftsman = new ContainerCraftsman(componentCraftsman);
new NodeCraftsman(componentCraftsman, containerCraftsman).Draw(root, Position.Default, canvas.GetSize());
componentCraftsman.Draw(_component, Position.Default, canvas.GetSize());
Mock.Get(canvas).Verify(w => w.Paint(content), Times.Once());
Mock.Get(canvas).Verify(w => w.SetPencil(expectedPosition, 0), Times.Once());
@ -78,14 +73,12 @@ public class NodeCraftsmanTests
public void DrawWithVerticalAlignment(Vertical alignment, string content, int canvasSize, int[] expectedPositions)
{
var canvas = Mock.Of<ICanvas>(w => w.Width == canvasSize && w.Height == canvasSize);
var component = Mock.Of<IComponent>(c => c.Draw() == new Sketch(content) &&
c.Alignment == new Alignment(Horizontal.Left, alignment));
var nodes = new Nodes { component };
var root = Mock.Of<IContainer>(r => r.GetNodes() == nodes);
_component.SetContent(content);
_component.SetAlignment(Horizontal.Left);
_component.SetAlignment(alignment);
var componentCraftsman = new ComponentCraftsman(canvas);
var containerCraftsman = new ContainerCraftsman(componentCraftsman);
new NodeCraftsman(componentCraftsman, containerCraftsman).Draw(root, Position.Default, canvas.GetSize());
componentCraftsman.Draw(_component, Position.Default, canvas.GetSize());
foreach (var expectedCursorPosition in expectedPositions)
{
@ -107,14 +100,12 @@ public class NodeCraftsmanTests
int expectedTop)
{
var canvas = Mock.Of<ICanvas>(w => w.Width == 6 && w.Height == 5);
var component = Mock.Of<IComponent>(c => c.Draw() == new Sketch("VV") &&
c.Alignment == new Alignment(horizontal, vertical));
var nodes = new Nodes { component };
var root = Mock.Of<IContainer>(r => r.GetNodes() == nodes);
_component.SetContent("VV");
_component.SetAlignment(horizontal);
_component.SetAlignment(vertical);
var componentCraftsman = new ComponentCraftsman(canvas);
var containerCraftsman = new ContainerCraftsman(componentCraftsman);
new NodeCraftsman(componentCraftsman, containerCraftsman).Draw(root, Position.Default, canvas.GetSize());
componentCraftsman.Draw(_component, Position.Default, canvas.GetSize());
Mock.Get(canvas).Verify(w => w.SetPencil(expectedLeft, expectedTop), Times.Once());
}
@ -130,7 +121,7 @@ public class NodeCraftsmanTests
var componentCraftsman = new ComponentCraftsman(canvas);
var containerCraftsman = new ContainerCraftsman(componentCraftsman);
new NodeCraftsman(componentCraftsman, containerCraftsman).Draw(root, Position.Default, canvas.GetSize());
containerCraftsman.Draw(root, Position.Default, canvas.GetSize());
Mock.Get(canvas).Verify(w => w.SetPencil(0, 0), Times.Once());
Mock.Get(canvas).Verify(w => w.Paint("Lorem"), Times.Once());
@ -177,7 +168,7 @@ public class NodeCraftsmanTests
var componentCraftsman = new ComponentCraftsman(canvas);
var containerCraftsman = new ContainerCraftsman(componentCraftsman);
new NodeCraftsman(componentCraftsman, containerCraftsman).Draw(root, Position.Default, canvas.GetSize());
containerCraftsman.Draw(root, Position.Default, canvas.GetSize());
Mock.Get(canvas).Verify(w => w.SetPencil(0, 0), Times.Exactly(1));
Mock.Get(canvas).Verify(w => w.SetPencil(6, 0), Times.Exactly(1));
@ -196,7 +187,7 @@ public class NodeCraftsmanTests
var componentCraftsman = new ComponentCraftsman(canvas);
var containerCraftsman = new ContainerCraftsman(componentCraftsman);
new NodeCraftsman(componentCraftsman, containerCraftsman).Draw(root, Position.Default, canvas.GetSize());
containerCraftsman.Draw(root, Position.Default, canvas.GetSize());
Mock.Get(canvas).Verify(w => w.SetPencil(0, 0), Times.Exactly(1));
Mock.Get(canvas).Verify(w => w.SetPencil(0, 1), Times.Exactly(1));
@ -204,20 +195,22 @@ public class NodeCraftsmanTests
}
[Theory]
[InlineData(Resizing.Hug, 5)]
[InlineData(Resizing.Fixed, 6)]
[InlineData(Resizing.Fixed, 3)]
[InlineData(Resizing.Adaptive, 10)]
public void DrawWithResizeContainer(Resizing resizing, int expectedCursorPosition)
public void DrawResizingContainer(Resizing resizing, int expectedCursorPosition)
{
var canvas = Mock.Of<ICanvas>(w => w.Width == 20 && w.Height == 2);
var container =
Mock.Of<IContainer>(c => c.GetNodes() == new Nodes { _component } && c.ResizingHorizontal == resizing);
Mock.Of<IContainer>(c =>
c.GetNodes() == new Nodes { _component } && c.ResizingHorizontal == resizing &&
c.GetFixedSize() == new Size(6, 2));
var nodes = new Nodes { container, _component };
var root = Mock.Of<IContainer>(r => r.GetNodes() == nodes && r.Orientation == Orientation.Horizontal);
var componentCraftsman = new ComponentCraftsman(canvas);
var containerCraftsman = new ContainerCraftsman(componentCraftsman);
new NodeCraftsman(componentCraftsman, containerCraftsman).Draw(root, Position.Default, canvas.GetSize());
containerCraftsman.Draw(root, Position.Default, canvas.GetSize());
Mock.Get(canvas).Verify(w => w.SetPencil(0, 0), Times.Exactly(1));
Mock.Get(canvas).Verify(w => w.SetPencil(expectedCursorPosition, 0), Times.Exactly(1));

View File

@ -9,7 +9,7 @@ public class LogoTests
{
var logo = new Logo();
var render = logo.Draw().ToString();
var render = logo.MakeSketch().ToString();
Assert.Equal(
" \u001b[38;2;132;186;100m\u256d\u2501\u2501\u2501\u2501\u2533\u256e\u001b[0m\u001b[38;2;113;121;126m\u2571\u2571\u001b[0m\u001b[38;2;132;186;100m\u256d\u2501\u2501\u2501\u256e\u001b[0m\n \u001b[38;2;132;186;100m\u2503\u256d\u256e\u256d\u256e\u2503\u2503\u001b[0m\u001b[38;2;113;121;126m\u2571\u2571\u001b[0m\u001b[38;2;132;186;100m\u2570\u256e\u256d\u256e\u2503\u001b[0m\n \u001b[38;2;132;186;100m\u2570\u256f\u2503\u2503\u2570\u252b\u2503\u001b[0m\u001b[38;2;113;121;126m\u2571\u2571\u2571\u001b[0m\u001b[38;2;132;186;100m\u2503\u2503\u2503\u2503\u001b[0m\n \u001b[38;2;113;121;126m\u2571\u2571\u001b[0m\u001b[38;2;132;186;100m\u2503\u2503\u001b[0m\u001b[38;2;113;121;126m\u2571\u001b[0m\u001b[38;2;132;186;100m\u2503\u2503\u001b[0m\u001b[38;2;113;121;126m\u2571\u001b[0m\u001b[38;2;132;186;100m\u256d\u256e\u2503\u2503\u2503\u2503\u001b[0m\n \u001b[38;2;113;121;126m\u2571\u2571\u2571\u001b[0m\u001b[38;2;132;186;100m\u2503\u2503\u001b[0m\u001b[38;2;113;121;126m\u2571\u001b[0m\u001b[38;2;132;186;100m\u2503\u2570\u2501\u256f\u2523\u256f\u2570\u256f\u2503\u001b[0m\n\u001b[38;2;113;121;126m\u2571\u2571\u2571\u2571\u001b[0m\u001b[38;2;132;186;100m\u2570\u256f\u001b[0m\u001b[38;2;113;121;126m\u2571\u001b[0m\u001b[38;2;132;186;100m\u2570\u2501\u2501\u2501\u253b\u2501\u2501\u2501\u256f\u001b[0m\n",

View File

@ -0,0 +1,22 @@
using FluentAssertions;
using TUI.Engine.Rendering;
namespace Widgets.Tests;
public class IntegerTests
{
[Fact]
public void IntegerGreaterMax()
{
var result = 5.Max(10);
result.Should().Be(5);
}
[Fact]
public void IntegerLessMax()
{
var result = 5.Max(3);
result.Should().Be(3);
}
}

View File

@ -0,0 +1,18 @@
using TUI.Engine.Nodes.Components;
namespace Widgets.Tests;
internal class TestComponent : ComponentBase
{
private string _content = "Lorem";
public void SetContent(string content)
{
_content = content;
}
public override Sketch DrawComponent()
{
return new Sketch(_content);
}
}