Add tests for GameVersionConverter and fix edge case (#1726)

- Adds tests for GameVersionConverter
- Refactors GameVersionConverter to reduce nesting
- Fixes an edge case in GameVersion deserialization in which the JsonConstructor will be invoked even if no properties match
- Adds a test for the GameVersion deserialization edge case
This commit is contained in:
Kara 2024-03-18 20:12:34 -07:00 committed by GitHub
parent 7fcd10ecd8
commit d393fa64b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 171 additions and 22 deletions

View file

@ -225,6 +225,17 @@ namespace Dalamud.Test.Game
Assert.Throws<ArgumentOutOfRangeException>(() => JsonConvert.DeserializeObject<GameVersion>(serialized));
}
[Fact]
public void VersionInvalidTypeDeserialization()
{
var serialized = """
{
"Value": "Hello"
}
""";
Assert.Throws<JsonSerializationException>(() => JsonConvert.DeserializeObject<GameVersion>(serialized));
}
[Fact]
public void VersionConstructorNegativeYear()
{