Ejemplo n.º 1
0
        public ActionResult GetPositionsTableForSport(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var table = tableCalculator.GeneratePositionTableForSport(id);
                return(Ok(table));
            }
            catch (SportDoesNotExistException e)
            {
                return(NotFound(e.Message));
            }
            catch (NoEncountersFoundForTeamException e)
            {
                return(NotFound(e.Message));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Ejemplo n.º 2
0
        public void GeneratePositionTableForDoubleEncounterModeTieTest()
        {
            PositionInEncounter scoreNacional = new PositionInEncounter {
                Id = 1, Position = 1, TeamId = nacional.Id
            };
            PositionInEncounter scoreCerro = new PositionInEncounter {
                Id = 2, Position = 1, TeamId = cerro.Id
            };
            Encounter encounter = new Encounter()
            {
                Id = 1, Teams = { eNacional, eCerro }, Results = { scoreNacional, scoreCerro }
            };

            encounterList.Add(encounter);
            mockEncounterBL.Setup(s => s.GetAllEncountersOfTeam(nacional.Id)).Returns(encounterList);
            mockEncounterBL.Setup(s => s.GetAllEncountersOfTeam(cerro.Id)).Returns(encounterList);
            ICollection <Score> positionTable = positionTableCalculator.GeneratePositionTableForSport(football.Id);

            Assert.IsTrue(positionTable.Count() == 2);
        }