-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for TwitchChat emote processor (#214)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8519b8e
commit 6469571
Showing
5 changed files
with
78 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/TagzApp.UnitTest/TwitchChat/ChatClient/GivenMessageWithEmotes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using SUT = TagzApp.Providers.TwitchChat.ChatClient; | ||
|
||
namespace TagzApp.UnitTest.TwitchChat.ChatClient; | ||
|
||
|
||
public class GivenMessageWithEmotes | ||
{ | ||
|
||
const string RawMessageWithEmotes = """ | ||
@badge-info=subscriber/65;badges=vip/1,subscriber/48,glitchcon2020/1;client-nonce=1b97cd0780e2dc2b5f61d800a6f7d278;color=#1E90FF;display-name=csharpfritz;emotes=302930318:8-18/140102:97-107;first-msg=0;flags=;id=c986dadb-d9d5-4cb2-b8bb-953792fb6a41;mod=0;returning-chatter=0;room-id=63208102;subscriber=1;tmi-sent-ts=1695218877167;turbo=0;user-id=96909659;user-type=;vip=1 :csharpfritz!csharpfritz@csharpfritz.tmi.twitch.tv PRIVMSG #fiercekittenz :Lasers! csharpGuess and challenge coins? I've wanted to pull the trigger on those for a while! kittenzHypu | ||
"""; | ||
|
||
[Fact] | ||
public void ShouldReturnMultipleEmotes() | ||
{ | ||
|
||
var outEmotes = SUT.IdentifyEmotes(RawMessageWithEmotes); | ||
|
||
Assert.Equal(2, outEmotes.Count); | ||
|
||
} | ||
|
||
[Fact] | ||
public void ShouldReturnCorrectEmotes() | ||
{ | ||
|
||
var outEmotes = SUT.IdentifyEmotes(RawMessageWithEmotes); | ||
var testEmote = outEmotes.First(); | ||
|
||
Assert.Contains("302930318", testEmote.ImageUrl); | ||
Assert.Equal(8, testEmote.Pos); | ||
Assert.Equal(11, testEmote.Length); | ||
|
||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/TagzApp.UnitTest/TwitchChat/ChatClient/GivenMessageWithoutEmotes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using SUT = TagzApp.Providers.TwitchChat.ChatClient; | ||
|
||
namespace TagzApp.UnitTest.TwitchChat.ChatClient; | ||
|
||
public class GivenMessageWithoutEmotes | ||
{ | ||
|
||
const string RawMessage = """ | ||
@badge-info=subscriber/65;badges=vip/1,subscriber/48,glitchcon2020/1;client-nonce=1b97cd0780e2dc2b5f61d800a6f7d278;color=#1E90FF;display-name=csharpfritz;emotes=;first-msg=0;flags=;id=c986dadb-d9d5-4cb2-b8bb-953792fb6a41;mod=0;returning-chatter=0;room-id=63208102;subscriber=1;tmi-sent-ts=1695218877167;turbo=0;user-id=96909659;user-type=;vip=1 :csharpfritz!csharpfritz@csharpfritz.tmi.twitch.tv PRIVMSG #fiercekittenz :Lasers! and challenge coins? I've wanted to pull the trigger on those for a while! | ||
"""; | ||
|
||
[Fact] | ||
public void ShouldReturnMultipleEmotes() | ||
{ | ||
|
||
var outEmotes = SUT.IdentifyEmotes(RawMessage); | ||
|
||
Assert.Empty(outEmotes); | ||
|
||
} | ||
|
||
} |