teamlead-dashboard/tests/TUI.Engine.Tests/Components/ComponentBaseTests.cs

69 lines
2.0 KiB
C#
Raw Normal View History

2024-03-06 21:49:54 +00:00
using FluentAssertions;
2024-03-15 19:13:09 +00:00
using TUI.Engine.Attributes.Alignments;
2024-03-16 19:39:58 +00:00
using TUI.Engine.Components;
2024-03-15 19:13:09 +00:00
using TUI.Engine.Tests.Stubs;
2024-03-06 21:49:54 +00:00
using TUI.Engine.Theme;
2024-03-16 19:39:58 +00:00
namespace TUI.Engine.Tests.Components;
2024-03-06 21:49:54 +00:00
2024-03-16 20:31:13 +00:00
public class ComponentBaseTests
2024-03-06 21:49:54 +00:00
{
[Fact]
2024-03-16 19:39:58 +00:00
[Trait("Category", nameof(IComponent))]
2024-03-06 21:49:54 +00:00
public void WhenUseChainingSaveAllChange()
{
2024-03-15 19:13:09 +00:00
var logo = new TestComponent();
2024-03-08 20:48:16 +00:00
logo.SetPadding(Level.Normal);
logo.SetAlignment(Vertical.Center);
logo.SetAlignment(Horizontal.Center);
2024-03-06 21:49:54 +00:00
2024-03-08 20:48:16 +00:00
logo.Padding.Top.Should().Be(Level.Normal);
logo.Padding.Left.Should().Be(Level.Normal);
logo.Padding.Bottom.Should().Be(Level.Normal);
logo.Padding.Right.Should().Be(Level.Normal);
logo.Alignment.Horizontal.Should().Be(Horizontal.Center);
logo.Alignment.Vertical.Should().Be(Vertical.Center);
2024-03-06 21:49:54 +00:00
}
[Fact]
2024-03-16 19:39:58 +00:00
[Trait("Category", nameof(IComponent))]
2024-03-06 21:49:54 +00:00
public void WhenSetPaddingsSaveAllChange()
{
2024-03-15 19:13:09 +00:00
var component = new TestComponent();
2024-03-06 21:49:54 +00:00
2024-03-08 20:48:16 +00:00
component.SetPadding(Level.Normal);
2024-03-06 21:49:54 +00:00
component.Padding.Top.Should().Be(Level.Normal);
component.Padding.Left.Should().Be(Level.Normal);
component.Padding.Bottom.Should().Be(Level.Normal);
component.Padding.Right.Should().Be(Level.Normal);
}
[Theory]
2024-03-16 19:39:58 +00:00
[Trait("Category", nameof(IComponent))]
2024-03-06 21:49:54 +00:00
[InlineData(Vertical.Bottom)]
[InlineData(Vertical.Center)]
[InlineData(Vertical.Top)]
public void WhenSetVerticalAlignSaveAllChange(Vertical alignment)
{
2024-03-15 19:13:09 +00:00
var component = new TestComponent();
2024-03-06 21:49:54 +00:00
2024-03-08 20:48:16 +00:00
component.SetAlignment(alignment);
2024-03-06 21:49:54 +00:00
component.Alignment.Vertical.Should().Be(alignment);
}
[Theory]
2024-03-16 19:39:58 +00:00
[Trait("Category", nameof(IComponent))]
2024-03-08 20:48:16 +00:00
[InlineData(Horizontal.Left)]
[InlineData(Horizontal.Center)]
[InlineData(Horizontal.Right)]
public void WhenSetHorizontalAlignSaveAllChange(Horizontal alignment)
2024-03-06 21:49:54 +00:00
{
2024-03-15 19:13:09 +00:00
var component = new TestComponent();
2024-03-06 21:49:54 +00:00
2024-03-08 20:48:16 +00:00
component.SetAlignment(alignment);
2024-03-06 21:49:54 +00:00
2024-03-08 20:48:16 +00:00
component.Alignment.Horizontal.Should().Be(alignment);
2024-03-06 21:49:54 +00:00
}
}