csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
using System.Linq;
|
|
using Avalonia.Controls.Presenters;
|
|
using Avalonia.UnitTests;
|
|
using Xunit;
|
|
|
|
namespace Avalonia.Controls.UnitTests.Presenters
|
|
{
|
|
public class TextPresenter_Tests
|
|
{
|
|
[Fact]
|
|
public void TextPresenter_Can_Contain_Null_With_Password_Char_Set()
|
|
{
|
|
using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
|
|
{
|
|
var target = new TextPresenter
|
|
{
|
|
PasswordChar = '*'
|
|
};
|
|
|
|
Assert.NotNull(target.TextLayout);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void TextPresenter_Can_Contain_Null_WithOut_Password_Char_Set()
|
|
{
|
|
using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
|
|
{
|
|
|
|
var target = new TextPresenter();
|
|
|
|
Assert.NotNull(target.TextLayout);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void Text_Presenter_Replaces_Formatted_Text_With_Password_Char()
|
|
{
|
|
using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
|
|
{
|
|
|
|
var target = new TextPresenter { PasswordChar = '*', Text = "Test" };
|
|
|
|
target.Measure(Size.Infinity);
|
|
|
|
Assert.NotNull(target.TextLayout);
|
|
|
|
var actual = string.Join(null,
|
|
target.TextLayout.TextLines.SelectMany(x => x.TextRuns).Select(x => x.Text.Span.ToString()));
|
|
|
|
Assert.Equal("****", actual);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|