Skip to content

Commit

Permalink
add - Added more GetEmojiFromEnum() tests
Browse files Browse the repository at this point in the history
---

We've added another test that uses enumeration from the emoji instance class.

---

Type: add
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Oct 16, 2024
1 parent 0e03036 commit 47ed5cd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Textify.Data/Unicode/Emoji.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Emoji
{
private readonly string name = "";
private readonly string sequence = "";
private readonly EmojiEnum emojiEnum = (EmojiEnum)(-1);
private readonly EmojiStatus status = EmojiStatus.Component;

/// <summary>
Expand All @@ -40,16 +41,23 @@ public class Emoji
public string Sequence =>
sequence;

/// <summary>
/// Emoji name enumeration
/// </summary>
public EmojiEnum Enum =>
emojiEnum;

/// <summary>
/// Emoji status
/// </summary>
public EmojiStatus Status =>
status;

internal Emoji(string name, string sequence, EmojiStatus status)
internal Emoji(string name, string sequence, EmojiEnum emojiEnum, EmojiStatus status)
{
this.name = name;
this.sequence = sequence;
this.emojiEnum = emojiEnum;
this.status = status;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Textify.EmojiArrayGen/ArrayGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static string PopulateEmojiArray((string name, string refName, string se
string emojiEnumRef = $"EmojiEnum.{refName}";

// Add the resultant emoji info
builder.Append($" {{ {emojiEnumRef}, new(\"{name}\", \"{sequence}\", {status}) }}");
builder.Append($" {{ {emojiEnumRef}, new(\"{name}\", \"{sequence}\", {emojiEnumRef}, {status}) }}");
if (i < emojis.Length - 1)
builder.AppendLine(",");
}
Expand Down
3 changes: 3 additions & 0 deletions Textify.Tests/Unicode/EmojiData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ public static class EmojiData

public static IEnumerable<object[]> AllEmojisFromEmojiNames =>
EmojiManager.GetEmojis().Select((emoji) => new object[] { emoji.Name, emoji.Name, emoji.Sequence }).ToArray();

public static IEnumerable<object[]> AllEmojisFromEmojiEnums =>
EmojiManager.GetEmojis().Select((emoji) => new object[] { emoji.Enum, emoji.Name, emoji.Sequence }).ToArray();
}
}
9 changes: 9 additions & 0 deletions Textify.Tests/Unicode/UnicodeQueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,14 @@ public void QueryEmojisFromEmojiNames(string emoji, string expectedName, string
}
found.ShouldBeTrue();
}

[TestMethod]
[DynamicData(nameof(EmojiData.AllEmojisFromEmojiEnums), typeof(EmojiData))]
public void QueryEmojiFromEmojiEnums(EmojiEnum emoji, string expectedName, string expectedSequence)
{
var emojiInstance = EmojiManager.GetEmojiFromEnum(emoji);
emojiInstance.Name.ShouldBe(expectedName);
emojiInstance.Sequence.ShouldBe(expectedSequence);
}
}
}

0 comments on commit 47ed5cd

Please sign in to comment.