From d77962b3dd57a17335dca6474528cd341eba6591 Mon Sep 17 00:00:00 2001 From: Dominik Krivohlavek Date: Sat, 11 Nov 2023 11:23:11 +0100 Subject: [PATCH] Add tests for feedback encode --- .../{ListenTests.cs => JsonEncodeTests.cs} | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) rename tests/Jellyfin.Plugin.ListenBrainz.Api.Tests/{ListenTests.cs => JsonEncodeTests.cs} (69%) diff --git a/tests/Jellyfin.Plugin.ListenBrainz.Api.Tests/ListenTests.cs b/tests/Jellyfin.Plugin.ListenBrainz.Api.Tests/JsonEncodeTests.cs similarity index 69% rename from tests/Jellyfin.Plugin.ListenBrainz.Api.Tests/ListenTests.cs rename to tests/Jellyfin.Plugin.ListenBrainz.Api.Tests/JsonEncodeTests.cs index 8ce98e64..40c36cfa 100644 --- a/tests/Jellyfin.Plugin.ListenBrainz.Api.Tests/ListenTests.cs +++ b/tests/Jellyfin.Plugin.ListenBrainz.Api.Tests/JsonEncodeTests.cs @@ -1,5 +1,7 @@ using System.Collections.ObjectModel; using Jellyfin.Plugin.ListenBrainz.Api.Models; +using Jellyfin.Plugin.ListenBrainz.Api.Models.Requests; +using Jellyfin.Plugin.ListenBrainz.Api.Resources; using Newtonsoft.Json; using Xunit; @@ -40,3 +42,20 @@ public void Listen_EncodeAndDecode() Assert.NotNull(deserializedListen); } } + +public class RecordingFeedbackTests +{ + [Theory] + [InlineData(FeedbackScore.Hated)] + [InlineData(FeedbackScore.Loved)] + [InlineData(FeedbackScore.Neutral)] + public void FeedbackValues_Encode(FeedbackScore score) + { + var request = new RecordingFeedbackRequest { Score = score }; + var actualJson = JsonConvert.SerializeObject(request, BaseClient.SerializerSettings); + Assert.NotNull(actualJson); + + var expectedJson = @"{""score"":" + (int)score + "}"; + Assert.Equal(expectedJson, actualJson); + } +}