Fixed link not dispalyed in markup in Style.cs and added unit test cases (#1750)

This commit is contained in:
Elementttto
2025-06-02 13:49:53 +05:30
committed by GitHub
parent 9efc426eb9
commit bd0e2d3e22
2 changed files with 31 additions and 0 deletions

View File

@ -226,6 +226,11 @@ public sealed class Style : IEquatable<Style>
builder.Add("on " + Background.ToMarkup());
}
if (Link != null)
{
builder.Add($"link={Link}");
}
return string.Join(" ", builder);
}

View File

@ -405,5 +405,31 @@ public sealed class StyleTests
// Then
result.ShouldBe("default on green");
}
[Fact]
public void Should_Return_Expected_Markup_For_Style_With_Only_Link()
{
// Given
var style = new Style(link:"https://spectreconsole.net/");
// When
var result = style.ToMarkup();
// Then
result.ShouldBe("link=https://spectreconsole.net/");
}
[Fact]
public void Should_Return_Expected_Markup_For_Style_With_Background_And_Link()
{
// Given
var style = new Style(background: Color.Blue, link: "https://spectreconsole.net/");
// When
var result = style.ToMarkup();
// Then
result.ShouldBe("default on blue link=https://spectreconsole.net/");
}
}
}