Пример #1
0
        public Form2()
        {
            InitializeComponent();

            _greyhounds = new List<Greyhound>();
            _players = new HashSet<Player>();

            //interval in miliseconds
            _timer = new Timer(50);
            _timer.Elapsed += OnTimedEvent;
            _timer.AutoReset = true;
            _timer.SynchronizingObject = this;

            _ticks = 0;

            _raceController = new RaceController(this, _timer, _greyhounds);
            _raceTrackDisplayController = new RaceTrackDisplayController(this, _greyhounds);

            InitializeRaceTrack();

            _greyhoundDisplayController = new GreyhoundDisplayController(_greyhounds);
            _playersDisplayController = new PlayersDisplayController(_players);

            MessageBoxService = new MessageBoxService();
        }
        public void ShouldNotAddPlayerIfMoneyIsBelowMinimumBet()
        {
            HashSet<Player> players = new HashSet<Player>();

            PlayersDisplayController controller = new PlayersDisplayController(players);

            controller.AddPlayer("Player", (Bet.MINIMUM_BET - 0.1m).ToString());

            Assert.AreEqual(0, players.Count);
        }
        public void ShouldNotAddPlayerIfMoneyIsStringOfLetters()
        {
            HashSet<Player> players = new HashSet<Player>();

            PlayersDisplayController controller = new PlayersDisplayController(players);

            controller.AddPlayer("Player", "sadfds");

            Assert.AreEqual(0, players.Count);
        }
        public void ShouldNotAddPlayerIfMoneyContainsDot()
        {
            HashSet<Player> players = new HashSet<Player>();

            PlayersDisplayController controller = new PlayersDisplayController(players);

            controller.AddPlayer("Player", "10.23");

            Assert.AreEqual(0, players.Count);
        }
        public void ShouldNotAddPlayerIfPlayerWithSuchNameAlreadyExists()
        {
            HashSet<Player> players = new HashSet<Player>();

            PlayersDisplayController controller = new PlayersDisplayController(players);

            string name  = "Player";

            controller.AddPlayer(name, "10");
            controller.AddPlayer(name, "20");

            Assert.AreEqual(1, players.Count);
        }