Skip to content

Commit

Permalink
add GameState.JsonDiffWith
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Jamrozik committed Jan 2, 2024
1 parent 95a7c04 commit b75becb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/game-lib-tests/GameSessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,8 @@ private static void VerifyGameSatesByJsonDiff(GameSessionController controller)
// find any bugs where serialization or deserialization incorrectly handled a field.

new JsonDiffAssertion(
lastSavedGameState,
currentGameState,
GameState.StateJsonSerializerOptions)
.Assert();
lastSavedGameState.JsonDiffWith(currentGameState)
).Assert();
}

[TearDown]
Expand Down
3 changes: 3 additions & 0 deletions src/game-lib/State/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public override bool Equals(object? obj)
public override int GetHashCode()
=> this.GetHashCode(StateJsonSerializerOptions);

public JsonDiff JsonDiffWith(GameState other)
=> new JsonDiff(this, other, StateJsonSerializerOptions);

private static JsonSerializerOptions GetJsonSerializerOptions()
{
// The difference between the returned options and converterOptions
Expand Down

0 comments on commit b75becb

Please sign in to comment.