Ejemplo n.º 1
0
        public void MatchMinuteValueIsComparableNotEqualValue()
        {
            var matchMinuteOne = new MatchMinute(4);
            var matchMinuteTwo = new MatchMinute(5);

            Assert.IsTrue(matchMinuteOne.Value != matchMinuteTwo.Value);
        }
Ejemplo n.º 2
0
        public void MatchMinuteValueIsComparableEqualValueOperator()
        {
            var matchMinuteOne = new MatchMinute(4);
            var matchMinuteTwo = new MatchMinute(4);

            Assert.IsTrue(matchMinuteOne.Value == matchMinuteTwo.Value);
        }
Ejemplo n.º 3
0
        private void playerListbox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Player selectedPlayer = new Player();

            selectedPlayer = (Player)playerListbox.SelectedItem;
            List <Guid>        PlayerInIdsList  = new List <Guid>(Exchanges.Select(ex => ex.PlayerInId).ToList());
            List <Guid>        PlayerOutIdsList = new List <Guid>(Exchanges.Select(ex => ex.PlayerOutId).ToList());
            List <MatchMinute> minutes          = new List <MatchMinute>();

            for (int i = 1; i <= MatchLength; i++)
            {
                MatchMinute min = new MatchMinute();
                min.Value = i;
                minutes.Add(min);
            }

            if (PlayerInIdsList.Contains(selectedPlayer.Id))
            {
                Exchange activeExchange = Exchanges.Find(ex => ex.PlayerInId == selectedPlayer.Id);
                minutes = minutes.Where(m => m.Value >= activeExchange.TimeOfExchange.Value).ToList();
            }

            if (PlayerOutIdsList.Contains(selectedPlayer.Id))
            {
                Exchange activeExchange = Exchanges.Find(ex => ex.PlayerOutId == selectedPlayer.Id);
                minutes = minutes.Where(m => m.Value <= activeExchange.TimeOfExchange.Value).ToList();
            }

            timeBox.ItemsSource = minutes;
        }
Ejemplo n.º 4
0
        public void MatchMinuteValueIsComparableEqualValueEquals()
        {
            var matchMinuteOne = new MatchMinute(4);
            var matchMinuteTwo = new MatchMinute(4);

            Assert.IsTrue(matchMinuteOne.Value.Equals(matchMinuteTwo.Value));
        }
Ejemplo n.º 5
0
        public void GoalThrowsNullExeption()
        {
            MatchMinute minute   = null;
            var         playerId = Guid.NewGuid();

            new Goal(minute, this.playerTeamIdOne, playerId);
        }
Ejemplo n.º 6
0
        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            Player player = (Player)playerListbox.SelectedItem;

            TimeOfEvent  = (MatchMinute)timeBox.SelectedItem;
            Result       = new Event(player.Id, TimeOfEvent);
            DialogResult = true;
        }
Ejemplo n.º 7
0
        public void MatchMinuteIsComparableEqualValue()
        {
            var matchMinuteOne = new MatchMinute(4);
            var matchMinuteTwo = new MatchMinute(4);
            var test           = matchMinuteOne == matchMinuteTwo;

            Assert.AreEqual(matchMinuteOne, matchMinuteTwo);
        }
Ejemplo n.º 8
0
        public void EqualsWorkWithValueAndReferenceTypes()
        {
            var name  = new Name("John", "Doe");
            var name2 = new Name("John", "Doe");
            var time  = new MatchMinute(30);
            var time2 = new MatchMinute(30);

            Assert.IsTrue(name.Equals(name2) && time.Equals(time2));
        }
Ejemplo n.º 9
0
        public void MatchMinuteWorksWithHashSet()
        {
            var matchMinuteOne = new MatchMinute(58);
            var matchMinuteTwo = new MatchMinute(58);
            var hashSet        = new HashSet <MatchMinute> {
                matchMinuteOne, matchMinuteTwo
            };

            Assert.IsTrue(hashSet.Count == 1);
        }
Ejemplo n.º 10
0
        private void RemoveAssistFromGame(Guid gameId, Guid playerId, int matchMinute)
        {
            var matchMin = new MatchMinute(matchMinute);
            var game     = this.FindById(gameId);

            foreach (var assist in game.Protocol.Assists)
            {
                if (assist.PlayerId == playerId && assist.MatchMinute == matchMin)
                {
                    game.Protocol.Assists.Remove(assist);
                    break;
                }
            }
        }
Ejemplo n.º 11
0
        private void RemoveYellowCardFromGame(Guid gameId, Guid playerId, int matchMinute)
        {
            var matchMin = new MatchMinute(matchMinute);
            var game     = this.FindById(gameId);

            foreach (var card in game.Protocol.Cards)
            {
                if (card.PlayerId == playerId && card.MatchMinute == matchMin && card.CardType == CardType.Yellow)
                {
                    game.Protocol.Cards.Remove(card);
                    break;
                }
            }
        }
Ejemplo n.º 12
0
        private void RemoveGoalFromGame(Guid gameId, Guid playerId, int matchMinute)
        {
            var matchMin = new MatchMinute(matchMinute);
            var game     = this.FindById(gameId);

            foreach (var goal in game.Protocol.Goals)
            {
                if (goal.PlayerId == playerId && goal.MatchMinute == matchMin)
                {
                    game.Protocol.Goals.Remove(goal);
                    break;
                }
            }
        }
Ejemplo n.º 13
0
        private void RemovePenaltyFromGame(Guid gameId, Guid playerId, int matchMinute)
        {
            var matchMin = new MatchMinute(matchMinute);
            var game     = this.FindById(gameId);

            foreach (var penalty in game.Protocol.Penalties)
            {
                if (penalty.PlayerId == playerId && penalty.MatchMinute == matchMin)
                {
                    game.Protocol.Penalties.Remove(penalty);
                    if (penalty.IsGoal)
                    {
                        this.RemoveGoalFromGame(gameId, playerId, matchMinute);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 14
0
        public void MatchMinuteCantBeMoreThan120()
        {
            var matchMinute = new MatchMinute(121);

            Assert.IsTrue(matchMinute.Value == 121);
        }
Ejemplo n.º 15
0
        public void MatchMinuteCanBeAssignedValidValue()
        {
            var matchMinute = new MatchMinute(90);

            Assert.IsTrue(matchMinute.Value == 90);
        }
Ejemplo n.º 16
0
        public void MatchMinuteToStringMoreThan90()
        {
            var matchMinute = new MatchMinute(91);

            Assert.AreEqual(matchMinute.ToString(), "90+1");
        }
Ejemplo n.º 17
0
        public void MatchMinuteToStringLessThan91()
        {
            var matchMinute = new MatchMinute(90);

            Assert.AreEqual(matchMinute.ToString(), "90");
        }
Ejemplo n.º 18
0
        public void MatchMinuteCantBeLessThanOneMinute()
        {
            var matchMinute = new MatchMinute(0);

            Assert.IsTrue(matchMinute.Value == 1);
        }
Ejemplo n.º 19
0
 private void Ok_Click(object sender, RoutedEventArgs e)
 {
     MatchMinute.TryParse(timeBox.SelectedIndex + 1, out TimeOfEvent);
     Result       = new Exchange(PlayerOut.Id, PlayerIn.Id, TimeOfEvent);
     DialogResult = true;
 }