/// <summary>
        /// Creates a lobby object and stores it on the system.
        /// The lobby created by this method will be a non-private one, so anyone will
        /// be able to join
        /// </summary>
        /// <param name="name">The name of the lobby</param>
        /// <param name="playerLimit">The player limit(minimum of 2, maximum of 4)</param>
        /// <returns>The created lobby object</returns>
        public Lobby CreateLobby(string name, int playerLimit)
        {
            if (!CheckLimits(name, playerLimit))
            {
                return(null);
            }

            Lobby lobby = BuildLobby(name, playerLimit, "");

            lobbyContainer.Add(lobby);
            return(lobby);
        }
示例#2
0
        public void Setup()
        {
            container         = LobbyContainer.GetInstance();
            accountController = new AccountControllerMock();
            controller        = new LobbyController(container, accountController);
            lobby             = new Lobby()
            {
                Id      = Guid.NewGuid(),
                Limit   = 3,
                Players = new List <Account>(),
            };
            account = new Account()
            {
                Id = Guid.NewGuid(),
            };

            container.Add(lobby);
            accountController.InsertAccount(account);
        }
示例#3
0
        public void Test_JoinLobby_AccountAlreadyInAnotherLobby_Fails()
        {
            // Setup

            Lobby dummy = new Lobby()
            {
                Id      = Guid.NewGuid(),
                Players = new List <Account>(),
            };

            dummy.Players.Add(account);
            container.Add(dummy);

            int expectedPlayerCount = lobby.Players.Count;

            // Action
            bool result = controller.JoinLobby(account.Id, lobby.Id, "");

            // Assert
            Assert.IsFalse(result);
            Assert.AreEqual(expectedPlayerCount, lobby.Players.Count);
        }