当前位置: 首页>>代码示例>>C#>>正文


C# PlayerType.ToList方法代码示例

本文整理汇总了C#中PlayerType.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerType.ToList方法的具体用法?C# PlayerType.ToList怎么用?C# PlayerType.ToList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerType的用法示例。


在下文中一共展示了PlayerType.ToList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: testRanking

        public void testRanking()
        {
            ClearAllData();
            var playerLogic = (IPlayerManipulations)getInterfaceImplementation(typeof(IPlayerManipulations));
            var teamLogic = (ITeamManipulations)getInterfaceImplementation(typeof(ITeamManipulations));
            var gameLogic = (IGameManipulations)getInterfaceImplementation(typeof(IGameManipulations));
            var matchLogic = (IMatchManipulations)getInterfaceImplementation(typeof(IMatchManipulations));
            var rankingLogic = (IRankingSource)getInterfaceImplementation(typeof(IRankingSource));

            var players = new PlayerType[20];
            for (int i = 0; i < players.Length; i++)
            {
                players[i] = new PlayerType() { Name = $"test{i}", Mail = $"test{i}", Tag = $"test{i}" };
                playerLogic.AddOrUpdatePlayer(players[i]);
            }

            var game1 = new GameType() { Name = "game1", ParticipantType = ParticipantTypes.All };
            gameLogic.AddOrUpdateGame(game1);


            for (int i = 0; i < 5; i++)
            {
                var scores = new List<int>();
                for (int j = 0; j < players.Length; j++)
                {
                    scores.Add(j + 1);
                }
                var match = new SoloMatch()
                {
                    GameID = game1,
                    Category = MatchCategories.Training,
                    dateTime = DateTime.Now,
                    Players = players.ToList(),
                    Scores = scores
                };
                matchLogic.AddOrUpdateSoloMatch(match);
            }

            var rankings = rankingLogic.GetGameRankingsAll(game1, ParticipantTypes.All);
            Assert.IsTrue(rankings.Count == players.Length, $" - getGameRankingsAll, expected count = {players.Length}, was: {rankings.Count}");

            var rank = rankings.Where(r => r.Player == players[0]).FirstOrDefault();
            Assert.IsNotNull(rank, $" - getGameRankingsAll does not return correct players in rankings");
            Assert.IsTrue(rank.Ranking == Ranks.Novice, $" - getGameRankingsAll, \"Novice\" expected,  was \"{rank.Ranking}\"");

            rank = rankings.Where(r => r.Player == players[5]).FirstOrDefault();
            Assert.IsNotNull(rank, $" - getGameRankingsAll does not return correct players in rankings");
            Assert.IsTrue(rank.Ranking == Ranks.Competent, $" - getGameRankingsAll, \"Competent\" expected, was \"{rank.Ranking}\"");

            rank = rankings.Where(r => r.Player == players[14]).FirstOrDefault();
            Assert.IsNotNull(rank, $" - getGameRankingsAll does not return correct players in rankings");
            Assert.IsTrue(rank.Ranking == Ranks.Advanced, $" - getGameRankingsAll, \"Advanced\" expected, was \"{rank.Ranking}\"");
            rank = rankings.Where(r => r.Player == players[19]).FirstOrDefault();
            Assert.IsNotNull(rank, $" - getGameRankingsAll does not return correct players in rankings");
            Assert.IsTrue(rank.Ranking == Ranks.Elite, $" - getGameRankingsAll, \"Elite\" expected, was \"{rank.Ranking}\"");
        }
开发者ID:ikdoeict-notes,项目名称:programmeren-3,代码行数:56,代码来源:LogicTests.cs


注:本文中的PlayerType.ToList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。