Esempio n. 1
0
        public virtual void SetUpSteps()
        {
            AddStep("reset counts", () =>
            {
                spectatorClient.Invocations.Clear();
                lastHeaders.Clear();
            });

            AddStep("set local user", () => ((DummyAPIAccess)API).LocalUser.Value = new APIUser
            {
                Id = 1,
            });

            AddStep("populate users", () =>
            {
                MultiplayerUsers.Clear();
                for (int i = 0; i < total_users; i++)
                {
                    MultiplayerUsers.Add(CreateUser(i));
                }
            });

            AddStep("create leaderboard", () =>
            {
                Leaderboard?.Expire();

                Beatmap.Value       = CreateWorkingBeatmap(Ruleset.Value);
                var playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
                OsuScoreProcessor scoreProcessor = new OsuScoreProcessor();
                scoreProcessor.ApplyBeatmap(playableBeatmap);

                Child = scoreProcessor;

                LoadComponentAsync(Leaderboard = CreateLeaderboard(scoreProcessor), Add);
            });

            AddUntilStep("wait for load", () => Leaderboard.IsLoaded);

            AddStep("check watch requests were sent", () =>
            {
                foreach (var user in MultiplayerUsers)
                {
                    spectatorClient.Verify(s => s.WatchUser(user.UserID), Times.Once);
                }
            });
        }
Esempio n. 2
0
        public new void SetUpSteps()
        {
            AddStep("reset", () =>
            {
                Clear();

                clocks = new Dictionary <int, ManualClock>
                {
                    { PLAYER_1_ID, new ManualClock() },
                    { PLAYER_2_ID, new ManualClock() }
                };

                foreach ((int userId, var _) in clocks)
                {
                    SpectatorClient.SendStartPlay(userId, 0);
                    OnlinePlayDependencies.MultiplayerClient.AddUser(new APIUser {
                        Id = userId
                    });
                }
            });

            AddStep("create leaderboard", () =>
            {
                Beatmap.Value      = CreateWorkingBeatmap(Ruleset.Value);
                var playable       = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
                var scoreProcessor = new OsuScoreProcessor();
                scoreProcessor.ApplyBeatmap(playable);

                LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(Ruleset.Value, scoreProcessor, clocks.Keys.Select(id => new MultiplayerRoomUser(id)).ToArray())
                {
                    Expanded = { Value = true }
                }, Add);
            });

            AddUntilStep("wait for load", () => leaderboard.IsLoaded);
            AddUntilStep("wait for user population", () => leaderboard.ChildrenOfType <GameplayLeaderboardScore>().Count() == 2);

            AddStep("add clock sources", () =>
            {
                foreach ((int userId, var clock) in clocks)
                {
                    leaderboard.AddClock(userId, clock);
                }
            });
        }