mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-04-21 02:02:31 -04:00
39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using System.Reflection;
|
|
using allstarr.Controllers;
|
|
|
|
namespace allstarr.Tests;
|
|
|
|
public class JellyfinSearchResponseSerializationTests
|
|
{
|
|
[Fact]
|
|
public void SerializeSearchResponseJson_PreservesPascalCaseShape()
|
|
{
|
|
var payload = new
|
|
{
|
|
Items = new[]
|
|
{
|
|
new Dictionary<string, object?>
|
|
{
|
|
["Name"] = "BTS",
|
|
["Type"] = "MusicAlbum"
|
|
}
|
|
},
|
|
TotalRecordCount = 1,
|
|
StartIndex = 0
|
|
};
|
|
|
|
var method = typeof(JellyfinController).GetMethod(
|
|
"SerializeSearchResponseJson",
|
|
BindingFlags.NonPublic | BindingFlags.Static);
|
|
|
|
Assert.NotNull(method);
|
|
|
|
var closedMethod = method!.MakeGenericMethod(payload.GetType());
|
|
var json = (string)closedMethod.Invoke(null, new object?[] { payload })!;
|
|
|
|
Assert.Equal(
|
|
"{\"Items\":[{\"Name\":\"BTS\",\"Type\":\"MusicAlbum\"}],\"TotalRecordCount\":1,\"StartIndex\":0}",
|
|
json);
|
|
}
|
|
}
|