Ejemplo n.º 1
0
        public void GenerateHomeAwayMatchFixture6TeamsTest()
        {
            ICollection <Encounter> fixtureResult = homeAwayFixture.GenerateFixture(teams);
            ICollection <Team>      copy          = new List <Team>(teams);
            bool everyMatch = true;

            foreach (Match actualMatch in GenereteMatchesHomeAway(copy))
            {
                everyMatch = everyMatch && CheckMatchInFixture(fixtureResult, actualMatch);
            }
            Assert.AreEqual(30, fixtureResult.Count);
            Assert.IsTrue(everyMatch);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            List <Fixture> population = new List <Fixture>();

            while (population.Count < POPULATION)
            {
                Fixture f = FixtureGenerator.GenerateFixture();
                population.Add(f);
            }

            Console.WriteLine("\n TOTAL FIXTURES: " + population.Count);

            for (int j = 0; j < ITERATIONS; j++)
            {
                // Validate
                Validate(population);

                // Select
                population = RankingSelection.Select(population);

                PrintParcialInformation(population);

                if (population.Count < 200)
                {
                    break;
                }

                // Mix
                for (int i = 0; i < population.Count - 1; i += 2)
                {
                    population[i].MixWithOther(population[i + 1]);
                }

                for (int i = 0; i < population.Count; i++)
                {
                    population[i].ResetAptitudeValue();
                }
            }

            PrintFinalInformation(population);

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        private ICollection <EncounterDto> AddFixture(ICollection <Team> teamsCollection)
        {
            ICollection <Encounter> added = new List <Encounter>();

            try
            {
                ICollection <Encounter> generatedMatches = fixtureAlgorithm.GenerateFixture(teamsCollection);
                AddMatches(ref added, generatedMatches);
                logger.Log(LogType.FIXTURE, LogMessage.FIXTURE_OK, GetConnectedUserName(), DateTime.Now);
            }
            catch (TeamAlreadyHasEncounterException e)
            {
                RollBack(added);
                logger.Log(LogType.FIXTURE, LogMessage.FIXTURE_WRONG + " " + e.Message, GetConnectedUserName(), DateTime.Now);
                throw new WrongFixtureException(e.Message);
            }
            catch (InvalidTeamCountException e)
            {
                RollBack(added);
                logger.Log(LogType.FIXTURE, LogMessage.FIXTURE_WRONG + " " + e.Message, GetConnectedUserName(), DateTime.Now);
                throw new WrongFixtureException(e.Message);
            }
            return(added.Select(e => mapper.ToDto(e)).ToList());
        }