mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Add test for ranked/unranked user display
This commit is contained in:
parent
c112177559
commit
097402677d
@ -2,12 +2,14 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Profile;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
@ -49,5 +51,42 @@ namespace osu.Game.Tests.Visual.Online
|
||||
IsOnline = false,
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRankedState()
|
||||
{
|
||||
AddStep("Show ranked user", () => header.User.Value = new APIUser
|
||||
{
|
||||
Id = 2001,
|
||||
Username = "RankedUser",
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
IsRanked = true,
|
||||
GlobalRank = 15000,
|
||||
CountryRank = 1500,
|
||||
RankHistory = new APIRankHistory
|
||||
{
|
||||
Mode = @"osu",
|
||||
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("Show unranked user", () => header.User.Value = new APIUser
|
||||
{
|
||||
Id = 2002,
|
||||
Username = "UnrankedUser",
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
IsRanked = false,
|
||||
// web will sometimes return non-empty rank history even for unranked users.
|
||||
RankHistory = new APIRankHistory
|
||||
{
|
||||
Mode = @"osu",
|
||||
Data = Enumerable.Range(2345, 85).ToArray()
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
ProfileOrder = new[] { "me" },
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
IsRanked = true,
|
||||
GlobalRank = 2148,
|
||||
CountryRank = 1,
|
||||
PP = 4567.89m,
|
||||
|
@ -27,6 +27,9 @@ namespace osu.Game.Users
|
||||
public int Progress;
|
||||
}
|
||||
|
||||
[JsonProperty(@"is_ranked")]
|
||||
public bool IsRanked;
|
||||
|
||||
[JsonProperty(@"global_rank")]
|
||||
public int? GlobalRank;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user