Skip to content

Commit

Permalink
Merge pull request #25703 from bdach/solo-score-info-serialisation-test
Browse files Browse the repository at this point in the history
Ensure that `SoloScoreInfo` serialisation result does not contain interface members
  • Loading branch information
peppy authored Dec 8, 2023
2 parents 5991c49 + 9a83d7b commit a553387
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions osu.Game.Tests/Online/TestSoloScoreInfoJsonSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NUnit.Framework;
using osu.Game.IO.Serialization;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring;
using osu.Game.Tests.Resources;

namespace osu.Game.Tests.Online
Expand Down Expand Up @@ -36,5 +37,31 @@ public void TestScoreSerialisationWithoutSettings()
Assert.That(serialised, Contains.Substring("large_tick_hit"));
Assert.That(serialised, Contains.Substring("\"rank\":\"S\""));
}

/// <summary>
/// Ensures that the proxy implementations of <see cref="IScoreInfo"/> by <see cref="SoloScoreInfo"/>
/// do not get serialised to JSON.
/// </summary>
[Test]
public void TestScoreSerialisationSkipsInterfaceMembers()
{
var score = SoloScoreInfo.ForSubmission(TestResources.CreateTestScoreInfo());

string[] variants =
{
JsonConvert.SerializeObject(score),
score.Serialize()
};

foreach (string serialised in variants)
{
Assert.That(serialised, Does.Not.Contain("\"online_id\":"));
Assert.That(serialised, Does.Not.Contain("\"user\":"));
Assert.That(serialised, Does.Not.Contain("\"date\":"));
Assert.That(serialised, Does.Not.Contain("\"legacy_online_id\":"));
Assert.That(serialised, Does.Not.Contain("\"beatmap\":"));
Assert.That(serialised, Does.Not.Contain("\"ruleset\":"));
}
}
}
}

0 comments on commit a553387

Please sign in to comment.