This struct is used for representing the players in the PlayersInGameEventArgs class.
 public void PopulateWithArgs809()
 {
     PlayersInGameEventArgs playersInGameEventArgs;
     PlayerInGame[] playerInGames = new PlayerInGame[1];
     playersInGameEventArgs = new PlayersInGameEventArgs(playerInGames);
     ((GameEventArgs)playersInGameEventArgs).SenderId = 0;
     ((GameEventArgs)playersInGameEventArgs).EventId = (string)null;
     ((GameEventArgs)playersInGameEventArgs).EventType = (EventType)0;
     ((GameEventArgs)playersInGameEventArgs).NeedResponse = false;
     string[] ss = new string[3];
     ss[0] = "1";
     ss[1] = "0";
     ss[2] = "0";
     this.PopulateWithArgs(playersInGameEventArgs, ss);
     Assert.IsNotNull((object)playersInGameEventArgs);
     Assert.AreEqual<int>(1, playersInGameEventArgs.NumberOfPlayers);
     Assert.IsNotNull(playersInGameEventArgs.Players);
     Assert.AreEqual<int>(1, playersInGameEventArgs.Players.Length);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[0].Id);
     Assert.AreEqual<string>("0", playersInGameEventArgs.Players[0].Nickname);
     Assert.AreEqual<int>(0, ((GameEventArgs)playersInGameEventArgs).SenderId);
     Assert.AreEqual<string>
     ((string)null, ((GameEventArgs)playersInGameEventArgs).EventId);
     Assert.AreEqual<EventType>
     ((EventType)0, ((GameEventArgs)playersInGameEventArgs).EventType);
     Assert.AreEqual<bool>
     (false, ((GameEventArgs)playersInGameEventArgs).NeedResponse);
 }
예제 #2
0
        public PlayersInGameEventArgs(PlayerInGame[] playersIngame)
        {
            Contract.Requires(playersIngame != null);
            Contract.Requires(playersIngame.Length > 0);

            NumberOfPlayers = playersIngame.Length;
            Players = playersIngame;
        }
 public void PopulateWithArgsThrowsContractException973()
 {
     try
     {
       PlayersInGameEventArgs playersInGameEventArgs;
       PlayerInGame[] playerInGames = new PlayerInGame[1];
       playersInGameEventArgs = new PlayersInGameEventArgs(playerInGames);
       ((GameEventArgs)playersInGameEventArgs).SenderId = 0;
       ((GameEventArgs)playersInGameEventArgs).EventId = (string)null;
       ((GameEventArgs)playersInGameEventArgs).EventType = (EventType)0;
       ((GameEventArgs)playersInGameEventArgs).NeedResponse = false;
       string[] ss = new string[1];
       this.PopulateWithArgs(playersInGameEventArgs, ss);
       throw
     new AssertFailedException("expected an exception of type ContractException");
     }
     catch(Exception ex)
     {
       if (!PexContract.IsContractException(ex))
     throw ex;
     }
 }
예제 #4
0
        public void FirePlayersInGameEvent()
        {
            PlayerInGame[] playersInGame = new PlayerInGame[Player.Instance.NumberOfPlayers];

            for (int i = 1; i <= Player.Instance.NumberOfPlayers; i++)
            {
                playersInGame[i - 1] = new PlayerInGame(i, Player.Instance.GetPlayerNick(i));
            }

            QueueEvent(EventType.PlayersInGame, new PlayersInGameEventArgs(playersInGame));
        }
예제 #5
0
        public override void PopulateWithArgs(string[] stringArgs)
        {
            Contract.Requires(stringArgs != null);
            Contract.Requires(stringArgs.Length >= 3);

            Contract.Requires(EventContractHelper.TryParseInt(stringArgs[0]) && int.Parse(stringArgs[0]) >= 1);
            Contract.Requires(Contract.ForAll(1, stringArgs.Length, i => (i % 2 == 1) ? EventContractHelper.TryParseInt(stringArgs[i]) : true));

            NumberOfPlayers = int.Parse(stringArgs[0]);
            Players = new PlayerInGame[NumberOfPlayers];

            string[] playerStrings = stringArgs.Skip(1).ToArray();

            int currPlayer = 0;
            for (int i = 0; i < playerStrings.Length; i += 2)
            {
                int id = int.Parse(playerStrings[i]);
                string nick = playerStrings[i + 1];
                Players[currPlayer] = new PlayerInGame(id, nick);
                currPlayer++;
            }
        }
 public void ToString01825()
 {
     PlayersInGameEventArgs playersInGameEventArgs;
     string s;
     PlayerInGame[] playerInGames = new PlayerInGame[13];
     PlayerInGame s0 = default(PlayerInGame);
     s0.Id = default(int);
     s0.Nickname = "";
     playerInGames[7] = s0;
     PlayerInGame s1 = default(PlayerInGame);
     s1.Id = default(int);
     s1.Nickname = "";
     playerInGames[8] = s1;
     PlayerInGame s2 = default(PlayerInGame);
     s2.Id = default(int);
     s2.Nickname = "";
     playerInGames[9] = s2;
     PlayerInGame s3 = default(PlayerInGame);
     s3.Id = default(int);
     s3.Nickname = "";
     playerInGames[10] = s3;
     PlayerInGame s4 = default(PlayerInGame);
     s4.Id = default(int);
     s4.Nickname = "";
     playerInGames[11] = s4;
     PlayerInGame s5 = default(PlayerInGame);
     s5.Id = default(int);
     s5.Nickname = "";
     playerInGames[12] = s5;
     playersInGameEventArgs = new PlayersInGameEventArgs(playerInGames);
     ((GameEventArgs)playersInGameEventArgs).SenderId = 0;
     ((GameEventArgs)playersInGameEventArgs).EventId = (string)null;
     ((GameEventArgs)playersInGameEventArgs).EventType = (EventType)0;
     ((GameEventArgs)playersInGameEventArgs).NeedResponse = false;
     s = this.ToString01(playersInGameEventArgs);
     Assert.AreEqual<string>("13,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,,0,", s);
     Assert.IsNotNull((object)playersInGameEventArgs);
     Assert.AreEqual<int>(13, playersInGameEventArgs.NumberOfPlayers);
     Assert.IsNotNull(playersInGameEventArgs.Players);
     Assert.AreEqual<int>(13, playersInGameEventArgs.Players.Length);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[0].Id);
     Assert.AreEqual<string>
     ((string)null, playersInGameEventArgs.Players[0].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[1].Id);
     Assert.AreEqual<string>
     ((string)null, playersInGameEventArgs.Players[1].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[2].Id);
     Assert.AreEqual<string>
     ((string)null, playersInGameEventArgs.Players[2].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[3].Id);
     Assert.AreEqual<string>
     ((string)null, playersInGameEventArgs.Players[3].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[4].Id);
     Assert.AreEqual<string>
     ((string)null, playersInGameEventArgs.Players[4].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[5].Id);
     Assert.AreEqual<string>
     ((string)null, playersInGameEventArgs.Players[5].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[6].Id);
     Assert.AreEqual<string>
     ((string)null, playersInGameEventArgs.Players[6].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[7].Id);
     Assert.AreEqual<string>("", playersInGameEventArgs.Players[7].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[8].Id);
     Assert.AreEqual<string>("", playersInGameEventArgs.Players[8].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[9].Id);
     Assert.AreEqual<string>("", playersInGameEventArgs.Players[9].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[10].Id);
     Assert.AreEqual<string>("", playersInGameEventArgs.Players[10].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[11].Id);
     Assert.AreEqual<string>("", playersInGameEventArgs.Players[11].Nickname);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[12].Id);
     Assert.AreEqual<string>("", playersInGameEventArgs.Players[12].Nickname);
     Assert.AreEqual<int>(0, ((GameEventArgs)playersInGameEventArgs).SenderId);
     Assert.AreEqual<string>
     ((string)null, ((GameEventArgs)playersInGameEventArgs).EventId);
     Assert.AreEqual<EventType>
     ((EventType)0, ((GameEventArgs)playersInGameEventArgs).EventType);
     Assert.AreEqual<bool>
     (false, ((GameEventArgs)playersInGameEventArgs).NeedResponse);
 }
 public void ToString01893()
 {
     PlayersInGameEventArgs playersInGameEventArgs;
     string s;
     PlayerInGame[] playerInGames = new PlayerInGame[1];
     playersInGameEventArgs = new PlayersInGameEventArgs(playerInGames);
     ((GameEventArgs)playersInGameEventArgs).SenderId = 0;
     ((GameEventArgs)playersInGameEventArgs).EventId = (string)null;
     ((GameEventArgs)playersInGameEventArgs).EventType = (EventType)0;
     ((GameEventArgs)playersInGameEventArgs).NeedResponse = false;
     s = this.ToString01(playersInGameEventArgs);
     Assert.AreEqual<string>("1,0,", s);
     Assert.IsNotNull((object)playersInGameEventArgs);
     Assert.AreEqual<int>(1, playersInGameEventArgs.NumberOfPlayers);
     Assert.IsNotNull(playersInGameEventArgs.Players);
     Assert.AreEqual<int>(1, playersInGameEventArgs.Players.Length);
     Assert.AreEqual<int>(0, playersInGameEventArgs.Players[0].Id);
     Assert.AreEqual<string>
     ((string)null, playersInGameEventArgs.Players[0].Nickname);
     Assert.AreEqual<int>(0, ((GameEventArgs)playersInGameEventArgs).SenderId);
     Assert.AreEqual<string>
     ((string)null, ((GameEventArgs)playersInGameEventArgs).EventId);
     Assert.AreEqual<EventType>
     ((EventType)0, ((GameEventArgs)playersInGameEventArgs).EventType);
     Assert.AreEqual<bool>
     (false, ((GameEventArgs)playersInGameEventArgs).NeedResponse);
 }
예제 #8
0
 public PlayerInGame Constructor(int id, string nickname)
 {
     PlayerInGame target = new PlayerInGame(id, nickname);
     return target;
     // TODO: add assertions to method PlayerInGameTest.Constructor(Int32, String)
 }
예제 #9
0
 public PlayersInGameEventArgs Constructor(PlayerInGame[] playersIngame)
 {
     PlayersInGameEventArgs target = new PlayersInGameEventArgs(playersIngame);
     return target;
     // TODO: add assertions to method PlayersInGameEventArgsTest.Constructor(PlayerInGame[])
 }