From 9a83d7be81d7f2d2115ab76283be02c0806525f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 8 Dec 2023 09:27:12 +0100 Subject: [PATCH] Ensure that `SoloScoreInfo` serialisation result does not contain interface members --- .../TestSoloScoreInfoJsonSerialization.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/osu.Game.Tests/Online/TestSoloScoreInfoJsonSerialization.cs b/osu.Game.Tests/Online/TestSoloScoreInfoJsonSerialization.cs index 19bc96c677..509768530f 100644 --- a/osu.Game.Tests/Online/TestSoloScoreInfoJsonSerialization.cs +++ b/osu.Game.Tests/Online/TestSoloScoreInfoJsonSerialization.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json; 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 @@ -36,5 +37,31 @@ namespace osu.Game.Tests.Online Assert.That(serialised, Contains.Substring("large_tick_hit")); Assert.That(serialised, Contains.Substring("\"rank\":\"S\"")); } + + /// + /// Ensures that the proxy implementations of by + /// do not get serialised to JSON. + /// + [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\":")); + } + } } }