teamlead-dashboard/tests/TUI.Controls.Tests/VersionComponentTests.cs

54 lines
2.4 KiB
C#
Raw Permalink Normal View History

2024-03-17 19:57:31 +00:00
using FluentAssertions;
using TUI.Controls.Components;
2024-06-14 11:02:21 +00:00
using TUI.Domain;
2024-03-17 19:57:31 +00:00
using TUI.Engine.Attributes;
using TUI.Engine.Components;
namespace TUI.Engine.Tests
{
public class VersionComponentTests
{
[Theory]
[Trait("Category", nameof(Sketch))]
2024-06-14 11:02:21 +00:00
[InlineData(VersionStatus.BeNice, "\u001b[38;2;132;186;100m10.12.33\u001b[0m")]
[InlineData(VersionStatus.SoGood, "\u001b[38;2;113;121;126m10.12.33\u001b[0m")]
[InlineData(VersionStatus.ToNew, "\u001b[38;2;37;121;159m10.12.33\u001b[0m")]
[InlineData(VersionStatus.TooOld, "\u001b[38;2;236;151;6m10.12.33\u001b[0m")]
public void DrawSketchVersionTypes(VersionStatus versionStatus, string expected)
2024-03-17 19:57:31 +00:00
{
2024-03-21 20:06:32 +00:00
var brand = new Brand("Docker", "󰡨", "#1d63ed");
2024-06-14 11:02:21 +00:00
var version = new VersionComponent("10.12.33", brand, versionStatus);
2024-03-17 19:57:31 +00:00
var sketch = (version as IComponent).MakeSketch(new Size(10, 2));
2024-06-14 11:02:21 +00:00
2024-03-17 19:57:31 +00:00
sketch.ToString().Should().Be(expected);
}
2024-06-14 11:02:21 +00:00
[Theory]
[Trait("Category", nameof(Dependency))]
[InlineData("1.0.0", "0.0.1", VersionStatus.ToNew)]
[InlineData("1.0.0", "0.1.1", VersionStatus.ToNew)]
[InlineData("1.0.0", "0.1.0", VersionStatus.ToNew)]
[InlineData("1.2.0", "1.0.0", VersionStatus.ToNew)]
[InlineData("1.2.0", "1.0.1", VersionStatus.ToNew)]
[InlineData("1.2.0", "1.1.0", VersionStatus.ToNew)]
[InlineData("1.0.0", "1.0.0-rc", VersionStatus.ToNew)]
[InlineData("1.0.0", "1.0.0", VersionStatus.SoGood)]
[InlineData("^1.0.0", "1.0.0", VersionStatus.SoGood)]
[InlineData("1.2.0", "1.3.0", VersionStatus.BeNice)]
[InlineData("1.3.1", "1.3.3", VersionStatus.BeNice)]
[InlineData("1.2.0", "2.1.0", VersionStatus.TooOld)]
[InlineData("1.2.0", "2.0.1", VersionStatus.TooOld)]
[InlineData("1.2.0", "2.3.1", VersionStatus.TooOld)]
public void ComparisonDependencies(string actual, string convention, VersionStatus expectedType)
{
var brand = new Brand("Poker", "󱢢", "#1d63ed");
var actualDependency = new Dependency(actual, brand);
var conventionDependency = new Dependency(convention, brand);
var status = actualDependency.Comparison(conventionDependency);
status.Should().Be(expectedType);
}
2024-03-17 19:57:31 +00:00
}
}