1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 01:23:44 +08:00

Ensure that SoloScoreInfo serialisation result does not contain interface members

This commit is contained in:
Bartłomiej Dach 2023-12-08 09:27:12 +01:00
parent 07da9d95a9
commit 9a83d7be81
No known key found for this signature in database

View File

@ -5,6 +5,7 @@ using Newtonsoft.Json;
using NUnit.Framework; using NUnit.Framework;
using osu.Game.IO.Serialization; using osu.Game.IO.Serialization;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring;
using osu.Game.Tests.Resources; using osu.Game.Tests.Resources;
namespace osu.Game.Tests.Online namespace osu.Game.Tests.Online
@ -36,5 +37,31 @@ namespace osu.Game.Tests.Online
Assert.That(serialised, Contains.Substring("large_tick_hit")); Assert.That(serialised, Contains.Substring("large_tick_hit"));
Assert.That(serialised, Contains.Substring("\"rank\":\"S\"")); 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\":"));
}
}
} }
} }