dbeec2e9f0
Refactor test code in Jellyfin.Extensions.Tests for clarity and consistency: - Use explicit object initializers and collection expressions - Standardize field naming and use of this. - Add/improve XML doc comments for test methods - Use new(...) syntax for Guid/Version instantiation - Convert file-scoped to block-scoped namespaces in key tests - Nest test classes and use instance methods in enum tests - Enable XML docs and suppress select warnings in csproj - No changes to test or converter logic; style and maintainability only
43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
// <copyright file="JsonStringConverterTests.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
namespace Jellyfin.Extensions.Tests.Json.Converters
|
|
{
|
|
using System.Text.Json;
|
|
using Jellyfin.Extensions.Json.Converters;
|
|
using Xunit;
|
|
|
|
public class JsonStringConverterTests
|
|
{
|
|
private readonly JsonSerializerOptions _jsonSerializerOptions = new()
|
|
{
|
|
Converters =
|
|
{
|
|
new JsonStringConverter(),
|
|
},
|
|
};
|
|
|
|
[Theory]
|
|
[InlineData("\"test\"", "test")]
|
|
[InlineData("123", "123")]
|
|
[InlineData("123.45", "123.45")]
|
|
[InlineData("true", "true")]
|
|
[InlineData("false", "false")]
|
|
public void Deserialize_String_Valid_Success(string input, string output)
|
|
{
|
|
string? deserialized = JsonSerializer.Deserialize<string>(input, this._jsonSerializerOptions);
|
|
Assert.Equal(deserialized, output);
|
|
}
|
|
|
|
[Fact]
|
|
public void Deserialize_Int32asInt32_Valid_Success()
|
|
{
|
|
const string? input = "123";
|
|
const int output = 123;
|
|
int deserialized = JsonSerializer.Deserialize<int>(input, this._jsonSerializerOptions);
|
|
Assert.Equal(output, deserialized);
|
|
}
|
|
}
|
|
}
|