using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using Avalonia.Media.TextFormatting.Unicode;
using Xunit;
namespace Avalonia.Visuals.UnitTests.Media.TextFormatting
{
///
/// This class is intended for use when the Unicode spec changes. Otherwise the containing tests are redundant.
/// To update the GraphemeBreak.trie run the test.
///
public class GraphemeBreakClassTrieGeneratorTests
{
[Theory(Skip = "Only run when we update the trie.")]
[ClassData(typeof(GraphemeEnumeratorTestDataGenerator))]
public void Should_Enumerate(string text, int expectedLength)
{
var enumerator = new GraphemeEnumerator(text.AsMemory());
Assert.True(enumerator.MoveNext());
Assert.Equal(expectedLength, enumerator.Current.Text.Length);
}
[Fact(Skip = "Only run when we update the trie.")]
public void Should_Enumerate_Other()
{
const string text = "ABCDEFGHIJ";
var enumerator = new GraphemeEnumerator(text.AsMemory());
var count = 0;
while (enumerator.MoveNext())
{
Assert.Equal(1, enumerator.Current.Text.Length);
count++;
}
Assert.Equal(10, count);
}
[Fact(Skip = "Only run when we update the trie.")]
public void Should_Generate_Trie()
{
GraphemeBreakClassTrieGenerator.Execute();
}
public class GraphemeEnumeratorTestDataGenerator : IEnumerable