34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using System.Text;
|
|
using NTP.Application.Grains.Registry;
|
|
|
|
namespace NTP.Tests;
|
|
|
|
public class BlacklistRemarksTests
|
|
{
|
|
private static readonly DateTime Expiry = new(2026, 11, 20, 6, 0, 0);
|
|
|
|
[Fact]
|
|
public void Short_remarks_are_unchanged_and_keep_the_release_date()
|
|
{
|
|
var text = RegistryRules.BlacklistRemarks("ملاحظة", Expiry);
|
|
Assert.StartsWith("ملاحظة، سيتم فك الانتظار", text);
|
|
Assert.EndsWith("11/20/2026 06:00", text);
|
|
}
|
|
|
|
[Fact]
|
|
public void Four_hundred_arabic_letters_still_fit_the_500_byte_column_and_keep_the_release_date()
|
|
{
|
|
var text = RegistryRules.BlacklistRemarks(new string('ب', 400), Expiry); // 800 bytes typed
|
|
Assert.True(Encoding.UTF8.GetByteCount(text) <= RegistryRules.BlacklistRemarksMaxBytes);
|
|
Assert.EndsWith("11/20/2026 06:00", text);
|
|
}
|
|
|
|
[Fact]
|
|
public void FitBytes_never_splits_a_character()
|
|
{
|
|
var fit = RegistryRules.FitBytes("ابت" + "😀" + "جد", 7); // 3 letters = 6 bytes, the emoji needs 4 more
|
|
Assert.Equal("ابت", fit);
|
|
Assert.Equal(string.Empty, RegistryRules.FitBytes(null, 10));
|
|
}
|
|
}
|