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

@ -109,26 +109,31 @@ public sealed class GameVersion : ICloneable, IComparable, IComparable<GameVersi
/// <summary>
/// Gets the year component.
/// </summary>
[JsonRequired]
public int Year { get; } = -1;
/// <summary>
/// Gets the month component.
/// </summary>
[JsonRequired]
public int Month { get; } = -1;
/// <summary>
/// Gets the day component.
/// </summary>
[JsonRequired]
public int Day { get; } = -1;
/// <summary>
/// Gets the major version component.
/// </summary>
[JsonRequired]
public int Major { get; } = -1;
/// <summary>
/// Gets the minor version component.
/// </summary>
[JsonRequired]
public int Minor { get; } = -1;
public static implicit operator GameVersion(string ver)