mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Merge pull request #6522 from iiSaLMaN/fix-incorrect-beatmap-set-info-equality
Fix incorrect beatmap set info equality check for local beatmapsets
This commit is contained in:
48
osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs
Normal file
48
osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.NonVisual
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class BeatmapSetInfoEqualityTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestOnlineWithOnline()
|
||||||
|
{
|
||||||
|
var ourInfo = new BeatmapSetInfo { OnlineBeatmapSetID = 123 };
|
||||||
|
var otherInfo = new BeatmapSetInfo { OnlineBeatmapSetID = 123 };
|
||||||
|
|
||||||
|
Assert.AreEqual(ourInfo, otherInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDatabasedWithDatabased()
|
||||||
|
{
|
||||||
|
var ourInfo = new BeatmapSetInfo { ID = 123 };
|
||||||
|
var otherInfo = new BeatmapSetInfo { ID = 123 };
|
||||||
|
|
||||||
|
Assert.AreEqual(ourInfo, otherInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDatabasedWithOnline()
|
||||||
|
{
|
||||||
|
var ourInfo = new BeatmapSetInfo { ID = 123, OnlineBeatmapSetID = 12 };
|
||||||
|
var otherInfo = new BeatmapSetInfo { OnlineBeatmapSetID = 12 };
|
||||||
|
|
||||||
|
Assert.AreEqual(ourInfo, otherInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCheckNullID()
|
||||||
|
{
|
||||||
|
var ourInfo = new BeatmapSetInfo { Status = BeatmapSetOnlineStatus.Loved };
|
||||||
|
var otherInfo = new BeatmapSetInfo { Status = BeatmapSetOnlineStatus.Approved };
|
||||||
|
|
||||||
|
Assert.AreNotEqual(ourInfo, otherInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -63,6 +63,21 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public bool Protected { get; set; }
|
public bool Protected { get; set; }
|
||||||
|
|
||||||
public bool Equals(BeatmapSetInfo other) => OnlineBeatmapSetID == other?.OnlineBeatmapSetID;
|
public bool Equals(BeatmapSetInfo other)
|
||||||
|
{
|
||||||
|
if (other == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (ID != 0 && other.ID != 0)
|
||||||
|
return ID == other.ID;
|
||||||
|
|
||||||
|
if (OnlineBeatmapSetID.HasValue && other.OnlineBeatmapSetID.HasValue)
|
||||||
|
return OnlineBeatmapSetID == other.OnlineBeatmapSetID;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Hash) && !string.IsNullOrEmpty(other.Hash))
|
||||||
|
return Hash == other.Hash;
|
||||||
|
|
||||||
|
return ReferenceEquals(this, other);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user