Skip to content

Commit bb00270

Browse files
committed
Add tests
1 parent 19657d4 commit bb00270

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ private static Comment CreateCommentWithMessage(string viewerDisplayName, string
9090
[InlineData(
9191
"{\"body\":\"viewer8 is gifting 5 Tier 1 Subs to streamer8's community! They've gifted a total of 349 in the channel! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"viewer8 is gifting 5 Tier 1 Subs to streamer8's community! They've gifted a total of 349 in the channel! \",\"emoticon\":null}],\"user_badges\":[{\"_id\":\"subscriber\",\"version\":\"6\"},{\"_id\":\"bits\",\"version\":\"50000\"}],\"user_color\":\"#DAA520\",\"emoticons\":[]}",
9292
HighlightType.GiftedMany)]
93+
// +Special case in separate method.
9394
// GiftedSingle
9495
[InlineData(
9596
"{\"body\":\"viewer8 gifted a Tier 1 sub to viewer9! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"viewer8 gifted a Tier 1 sub to viewer9! \",\"emoticon\":null}],\"user_badges\":[{\"_id\":\"subscriber\",\"version\":\"6\"},{\"_id\":\"bits\",\"version\":\"50000\"}],\"user_color\":\"#DAA520\",\"emoticons\":[]}",
@@ -153,17 +154,35 @@ public void CorrectlyIdentifiesHighlightTypes(string messageString, HighlightTyp
153154
Assert.Equal(expectedType, actualType);
154155
}
155156

156-
[Fact]
157-
public void CorrectlyIdentifiesAnonymousGiftSub()
157+
[Theory]
158+
[InlineData("{\"display_name\":\"Twitch\",\"_id\":\"12826\",\"name\":\"twitch\",\"bio\":\"Twitch is where thousands of communities come together for whatever, every day. \",\"created_at\":\"2007-05-22T10:39:54.238271Z\",\"updated_at\":\"2024-09-22T22:28:39.594659Z\",\"logo\":\"https://static-cdn.jtvnw.net/jtv_user_pictures/aa88230d-7af5-4053-a7cd-889e626d3382-profile_image-300x300.png\"}",
159+
"{\"body\":\"We added 13 Gift Subs AND 10 Bonus Gift Subs to viewer8's gift! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"We added 13 Gift Subs AND 10 Bonus Gift Subs to viewer8's gift! \",\"emoticon\":null}],\"user_badges\":[],\"user_color\":null,\"emoticons\":[]}")]
160+
[InlineData("{\"display_name\":\"Twitch\",\"_id\":\"12826\",\"name\":\"twitch\",\"bio\":\"Twitch is where thousands of communities come together for whatever, every day. \",\"created_at\":\"2007-05-22T10:39:54.238271Z\",\"updated_at\":\"2024-09-22T22:28:39.594659Z\",\"logo\":\"https://static-cdn.jtvnw.net/jtv_user_pictures/aa88230d-7af5-4053-a7cd-889e626d3382-profile_image-300x300.png\"}",
161+
"{\"body\":\"We added 1 Gift Subs to viewer8's gift! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"We added 1 Gift Subs to viewer8's gift! \",\"emoticon\":null}],\"user_badges\":[],\"user_color\":null,\"emoticons\":[]}")]
162+
public void CorrectlyIdentifiesSubtemberGiftedMany(string commenterString, string messageString)
163+
{
164+
const HighlightType EXPECTED_TYPE = HighlightType.GiftedMany;
165+
166+
var commenter = JsonSerializer.Deserialize<Commenter>(commenterString)!;
167+
var message = JsonSerializer.Deserialize<Message>(messageString)!;
168+
var comment = CreateCommentWithCommenterAndMessage(commenter, message);
169+
170+
var actualType = HighlightIcons.GetHighlightType(comment);
171+
172+
Assert.Equal(EXPECTED_TYPE, actualType);
173+
}
174+
175+
[Theory]
176+
[InlineData("{\"display_name\":\"AnAnonymousGifter\",\"_id\":\"274598607\",\"name\":\"ananonymousgifter\",\"type\":\"user\",\"bio\":\"?????????????????????????????\",\"created_at\":\"2018-11-12T21:57:31.811529Z\",\"updated_at\":\"2022-04-18T21:57:27.392173Z\",\"logo\":\"https://static-cdn.jtvnw.net/jtv_user_pictures/ae7b05c6-c924-44ab-8203-475a2d3e488c-profile_image-300x300.png\"}",
177+
"{\"body\":\"An anonymous user gifted a Tier 1 sub to viewer8! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"An anonymous user gifted a Tier 1 sub to viewer8! \",\"emoticon\":null}],\"user_badges\":[],\"user_color\":null,\"emoticons\":[]}")]
178+
[InlineData("{\"display_name\":\"Twitch\",\"_id\":\"12826\",\"name\":\"twitch\",\"bio\":\"Twitch is where thousands of communities come together for whatever, every day. \",\"created_at\":\"2007-05-22T10:39:54.238271Z\",\"updated_at\":\"2024-09-22T22:28:39.594659Z\",\"logo\":\"https://static-cdn.jtvnw.net/jtv_user_pictures/aa88230d-7af5-4053-a7cd-889e626d3382-profile_image-300x300.png\"}",
179+
"{\"body\":\"An anonymous user gifted a Tier 1 sub to viewer8! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"An anonymous user gifted a Tier 1 sub to viewer8! \",\"emoticon\":null}],\"user_badges\":[],\"user_color\":null,\"emoticons\":[]}")]
180+
public void CorrectlyIdentifiesAnonymousGiftSub(string commenterString, string messageString)
158181
{
159-
const string COMMENTER_STRING =
160-
"{\"display_name\":\"AnAnonymousGifter\",\"_id\":\"274598607\",\"name\":\"ananonymousgifter\",\"type\":\"user\",\"bio\":\"?????????????????????????????\",\"created_at\":\"2018-11-12T21:57:31.811529Z\",\"updated_at\":\"2022-04-18T21:57:27.392173Z\",\"logo\":\"https://static-cdn.jtvnw.net/jtv_user_pictures/ae7b05c6-c924-44ab-8203-475a2d3e488c-profile_image-300x300.png\"}";
161-
const string MESSAGE_STRING =
162-
"{\"body\":\"An anonymous user gifted a Tier 1 sub to viewer8! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"An anonymous user gifted a Tier 1 sub to viewer8! \",\"emoticon\":null}],\"user_badges\":[],\"user_color\":null,\"emoticons\":[]}";
163182
const HighlightType EXPECTED_TYPE = HighlightType.GiftedAnonymous;
164183

165-
var commenter = JsonSerializer.Deserialize<Commenter>(COMMENTER_STRING)!;
166-
var message = JsonSerializer.Deserialize<Message>(MESSAGE_STRING)!;
184+
var commenter = JsonSerializer.Deserialize<Commenter>(commenterString)!;
185+
var message = JsonSerializer.Deserialize<Message>(messageString)!;
167186
var comment = CreateCommentWithCommenterAndMessage(commenter, message);
168187

169188
var actualType = HighlightIcons.GetHighlightType(comment);

0 commit comments

Comments
 (0)