Esempio n. 1
0
 public void InitUserAfterCreateGame()
 {
     //a - arange
     //a - act
     var user = new User();
     var game = new GameObject(user);
     //a - assert
     Assert.IsTrue(game.PlayerBlack != null || game.PlayerWhite != null);
 }
Esempio n. 2
0
        public void UniqIDs()
        {
            //a - arange
            //a - act

            var game1 = new GameObject(null);
            var game2 = new GameObject(null);

            //a - assert
            Assert.AreNotEqual(game1.Id, game2.Id);
        }
Esempio n. 3
0
 private static void MatchMaking(object source, ElapsedEventArgs e)
 {
     if (PlayersQue.Count < 2) return;
     var players = PlayersQue.Values.ToArray();
     for (var i = 0; i < PlayersQue.Count/2; i++)
     {
         var game = new GameObject(players[i*2], players[i*2 + 1]) {Act = Act.InProgress};
         if (!Games.TryAdd(game.Id, game)) continue;
         User dummy;
         PlayersQue.TryRemove(players[i*2].Name, out dummy);
         PlayersQue.TryRemove(players[i*2 + 1].Name, out dummy);
         Messages.GetOrAdd(players[i * 2].Name, k => new List<Message>()).Add(MessageSender.GameIsReady(game.Id));
         Messages.GetOrAdd(players[i * 2 + 1].Name, k => new List<Message>()).Add(MessageSender.GameIsReady(game.Id));
     }
 }
Esempio n. 4
0
 public void GameIdNotZero()
 {
     var game1 = new GameObject(null);
     Assert.AreNotEqual(0, game1.Id);
 }