2021-07-19 04:02:40 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
2022-01-19 05:32:56 +00:00
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Rulesets.Mania;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2021-07-19 04:02:40 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.NonVisual
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class ScoreInfoTest
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDeepClone()
|
|
|
|
|
{
|
|
|
|
|
var score = new ScoreInfo();
|
|
|
|
|
|
|
|
|
|
score.Statistics.Add(HitResult.Good, 10);
|
|
|
|
|
score.Rank = ScoreRank.B;
|
|
|
|
|
|
|
|
|
|
var scoreCopy = score.DeepClone();
|
|
|
|
|
|
|
|
|
|
score.Statistics[HitResult.Good]++;
|
|
|
|
|
score.Rank = ScoreRank.X;
|
2022-01-26 05:25:55 +00:00
|
|
|
|
score.RealmUser.Username = "test";
|
2021-07-19 04:02:40 +00:00
|
|
|
|
|
|
|
|
|
Assert.That(scoreCopy.Statistics[HitResult.Good], Is.EqualTo(10));
|
|
|
|
|
Assert.That(score.Statistics[HitResult.Good], Is.EqualTo(11));
|
|
|
|
|
|
|
|
|
|
Assert.That(scoreCopy.Rank, Is.EqualTo(ScoreRank.B));
|
|
|
|
|
Assert.That(score.Rank, Is.EqualTo(ScoreRank.X));
|
2022-01-26 05:25:55 +00:00
|
|
|
|
|
2022-01-26 06:14:43 +00:00
|
|
|
|
Assert.That(scoreCopy.RealmUser.Username, Is.Empty);
|
|
|
|
|
Assert.That(score.RealmUser.Username, Is.EqualTo("test"));
|
2021-07-19 04:02:40 +00:00
|
|
|
|
}
|
2022-01-19 05:32:56 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestModsInitiallyEmpty()
|
|
|
|
|
{
|
|
|
|
|
var score = new ScoreInfo();
|
|
|
|
|
|
|
|
|
|
Assert.That(score.Mods, Is.Empty);
|
|
|
|
|
Assert.That(score.APIMods, Is.Empty);
|
|
|
|
|
Assert.That(score.ModsJson, Is.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestModsUpdatedCorrectly()
|
|
|
|
|
{
|
|
|
|
|
var score = new ScoreInfo
|
|
|
|
|
{
|
|
|
|
|
Mods = new Mod[] { new ManiaModClassic() },
|
|
|
|
|
Ruleset = new ManiaRuleset().RulesetInfo,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Assert.That(score.Mods, Contains.Item(new ManiaModClassic()));
|
|
|
|
|
Assert.That(score.APIMods, Contains.Item(new APIMod(new ManiaModClassic())));
|
|
|
|
|
Assert.That(score.ModsJson, Contains.Substring("CL"));
|
|
|
|
|
|
|
|
|
|
score.APIMods = new[] { new APIMod(new ManiaModDoubleTime()) };
|
|
|
|
|
|
|
|
|
|
Assert.That(score.Mods, Contains.Item(new ManiaModDoubleTime()));
|
|
|
|
|
Assert.That(score.APIMods, Contains.Item(new APIMod(new ManiaModDoubleTime())));
|
|
|
|
|
Assert.That(score.ModsJson, Contains.Substring("DT"));
|
|
|
|
|
|
|
|
|
|
score.Mods = new Mod[] { new ManiaModClassic() };
|
|
|
|
|
|
|
|
|
|
Assert.That(score.Mods, Contains.Item(new ManiaModClassic()));
|
|
|
|
|
Assert.That(score.APIMods, Contains.Item(new APIMod(new ManiaModClassic())));
|
|
|
|
|
Assert.That(score.ModsJson, Contains.Substring("CL"));
|
|
|
|
|
}
|
2021-07-19 04:02:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|