The Free Software Media System - Server Backend & API
Add serialize test
crobibero75ed532fca9e
diff --git a/tests/Jellyfin.Common.Tests/Json/JsonOmdbConverterTests.cs b/tests/Jellyfin.Common.Tests/Json/JsonOmdbConverterTests.csindex 03226cf31b..faed086a12 100644--- a/tests/Jellyfin.Common.Tests/Json/JsonOmdbConverterTests.cs+++ b/tests/Jellyfin.Common.Tests/Json/JsonOmdbConverterTests.cs@@ -64,5 +64,25 @@ namespace Jellyfin.Common.Tests.Jsonvar result = JsonSerializer.Deserialize<string>(Input, _options);Assert.Equal(Expected, result);}++ [Fact]+ public void Roundtrip_Valid_Success()+ {+ const string Input = "{\"Title\":\"Chapter 1\",\"Year\":\"2013\",\"Rated\":\"TV-MA\",\"Released\":\"01 Feb 2013\",\"Season\":\"N/A\",\"Episode\":\"N/A\",\"Runtime\":\"55 min\",\"Genre\":\"Drama\",\"Director\":\"David Fincher\",\"Writer\":\"Michael Dobbs (based on the novels by), Andrew Davies (based on the mini-series by), Beau Willimon (created for television by), Beau Willimon, Sam Forman (staff writer)\",\"Actors\":\"Kevin Spacey, Robin Wright, Kate Mara, Corey Stoll\",\"Plot\":\"Congressman Francis Underwood has been declined the chair for Secretary of State. He's now gathering his own team to plot his revenge. Zoe Barnes, a reporter for the Washington Herald, will do anything to get her big break.\",\"Language\":\"English\",\"Country\":\"USA\",\"Awards\":\"N/A\",\"Poster\":\"https://m.media-amazon.com/images/M/MV5BMTY5MTU4NDQzNV5BMl5BanBnXkFtZTgwMzk2ODcxMzE@._V1_SX300.jpg\",\"Ratings\":[{\"Source\":\"Internet Movie Database\",\"Value\":\"8.7/10\"}],\"Metascore\":\"N/A\",\"imdbRating\":\"8.7\",\"imdbVotes\":\"6736\",\"imdbID\":\"tt2161930\",\"seriesID\":\"N/A\",\"Type\":\"episode\",\"Response\":\"True\"}";+ var trip1 = JsonSerializer.Deserialize<OmdbProvider.RootObject>(Input, _options);+ Assert.NotNull(trip1);+ Assert.NotNull(trip1?.Title);+ Assert.Null(trip1?.Awards);+ Assert.Null(trip1?.Episode);+ Assert.Null(trip1?.Metascore);++ var serializedTrip1 = JsonSerializer.Serialize(trip1!, _options);+ var trip2 = JsonSerializer.Deserialize<OmdbProvider.RootObject>(serializedTrip1, _options);+ Assert.NotNull(trip2);+ Assert.NotNull(trip2?.Title);+ Assert.Null(trip2?.Awards);+ Assert.Null(trip2?.Episode);+ Assert.Null(trip2?.Metascore);+ }}}