Beispiel #1
0
        public void Result()
        {
            var json = Resources.Get("fighters.json");

            List <Fighter> fighters = JsonConvert.DeserializeObject <List <Fighter> >(json);

            List <int> selecteds = fighters.Select(i => i.Id).ToList();

            Result finals = _ruleContest.Contest(fighters, selecteds);

            Assert.IsNotNull(finals);
            Assert.AreEqual(finals.Winner.Id, 28);
            Assert.AreEqual(finals.Second.Id, 30);
            Assert.AreEqual(finals.Third.Id, 22);
        }
Beispiel #2
0
        public IActionResult Contest(Contest contest)
        {
            contest.Fighters = _fighters;

            string startValidation = _validation.StartValidation(contest.Fighters, contest.CheckBoxFighters);

            if (!string.IsNullOrEmpty(startValidation))
            {
                contest.ErrorMessage = startValidation;
            }
            else
            {
                Result winners = _rules.Contest(contest.Fighters, contest.CheckBoxFighters);
                return(View("Contest", winners));
            }

            return(View("Index", contest));
        }