mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Add targeted tests
This commit is contained in:
parent
fc212e5e5f
commit
e09dd5aa87
@ -1,5 +1,7 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using MediaBrowser.Common.Json;
|
using MediaBrowser.Common.Json;
|
||||||
|
using MediaBrowser.Common.Json.Converters;
|
||||||
using MediaBrowser.Providers.Plugins.Omdb;
|
using MediaBrowser.Providers.Plugins.Omdb;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@ -17,5 +19,39 @@ namespace Jellyfin.Common.Tests.Json
|
|||||||
Assert.Null(seasonRootObject?.Episode);
|
Assert.Null(seasonRootObject?.Episode);
|
||||||
Assert.Null(seasonRootObject?.Metascore);
|
Assert.Null(seasonRootObject?.Metascore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public static void Deserialize_Not_Available_Int_Success()
|
||||||
|
{
|
||||||
|
const string Input = "\"N/A\"";
|
||||||
|
var options = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
NumberHandling = JsonNumberHandling.AllowReadingFromString,
|
||||||
|
Converters =
|
||||||
|
{
|
||||||
|
new JsonOmdbNotAvailableStructConverter<int>()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = JsonSerializer.Deserialize<int?>(Input, options);
|
||||||
|
Assert.Null(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public static void Deserialize_Not_Available_String_Success()
|
||||||
|
{
|
||||||
|
const string Input = "\"N/A\"";
|
||||||
|
var options = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
Converters =
|
||||||
|
{
|
||||||
|
new JsonOmdbNotAvailableStringConverter()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
options.Converters.Add(new JsonOmdbNotAvailableStringConverter());
|
||||||
|
var result = JsonSerializer.Deserialize<string>(Input, options);
|
||||||
|
Assert.Null(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user