예제 #1
0
        public void AddRoom_failed2(decimal money_)
        {
            GameCity gameCity = new GameCity("收费开房", _cityManager, ticketPrice_: 50);
            int      preCount = gameCity.Rooms.Count;
            bool     success  = true;

            gameCity.FailAddRoomNotEnoughMoney += delegate { success = false; };
            // gameCity.DAddRoomChek += delegate { return true; };
            gameCity.AddRoom(_room);
            Assert.False(success);
        }
예제 #2
0
        public void AddRoom()
        {
            int preCount = _gameCity_ticket_0.Rooms.Count;

            _gameCity_ticket_0.AddRoom(_room);
            Assert.True(_gameCity_ticket_0.Rooms.Count - preCount == 1, "房间数量未增加1");
            Assert.Contains(_room, _gameCity_ticket_0.Rooms);
        }
예제 #3
0
        public void AddRoom_accountNotEnough_fail(decimal mony_)
        {
            bool _playAddRoomSuccess = true;

            _playerFactory.Setup(p => p.Account).Returns(mony_);
            _roomConfig.TicketPrice = 50;
            var  room     = new Room(_playerFactory.Object, _roomConfig);
            int  preCount = _gameCity_ticket_5.Rooms.Count;
            bool success  = true;

            _gameCity_ticket_5.FailAddRoomNotEnoughMoney += delegate { success = false; };
            _gameCity_ticket_5.AddRoom(room);
            Assert.True(_gameCity_ticket_5.Rooms.Count == preCount);
            Assert.False(success);
            Assert.False(_playAddRoomSuccess, "没能触发玩家开房失败对象事件");
        }
예제 #4
0
        public void AddRoom_deductMoney(decimal money_)
        {
            var gameCityConfig = new GameCityConfig()
            {
                TicketPrice = 5
            };

            gameCityConfig.DAddRoomChek += delegate { return(true); };
            GameCity gameCity = new GameCity(_cityManager, gameCityConfig);

            _playerFactory.Setup(p => p.Account).Returns(money_);
            _playerFactory.Setup(p => p.DecutMoney(5, ""));
            var room = new Room(_playerFactory.Object, _roomConfig);

            gameCity.AddRoom(room);
            _playerFactory.Verify(p => p.DecutMoney(gameCity.TicketPrice, ""));
        }
예제 #5
0
        public void AddRoom_success(decimal money_, decimal ticket_)
        {
            _playerFactory.Setup(p => p.Account).Returns(money_);
            _playerFactory.Setup(p => p.DecutMoney(ticket_, "")).Returns(true);
            var player         = _playerFactory.Object;
            var gameCityConfig = new GameCityConfig()
            {
                TicketPrice = ticket_
            };
            GameCity gameCity = new GameCity(_cityManager, gameCityConfig);
            var      room     = new Room(player, new RoomConfig(_inningGame));
            bool     result   = false;

            gameCity.AfterAddRoomHandler += delegate { result = true; };
            gameCity.AddRoom(room);
            Assert.True(result);
        }