public void GenerateRoundRobinWithFiveTeamsTest()
        {
            var encounters    = roundRobin.GenerateFixture(teamList, DateTime.Now);
            var NtimesNminus1 = teamList.Count * (teamList.Count - 1);

            Assert.IsTrue(encounters.Count == NtimesNminus1);
        }
        public void GenerateFixtureWithNoEncountersOnRepoTest()
        {
            DateTime date = new DateTime(2018, 10, 1, 12, 00, 00);
            ICollection <Encounter> encounters = freeForAll.GenerateFixture(teamList, date);
            int count = encounters.Count;
            var expectedGeneratedEncountersCount = (teamList.Count() * (teamList.Count() - 1)) / 2;

            Assert.IsTrue(count == expectedGeneratedEncountersCount);
        }
        public ICollection <Encounter> GenerateFixture(IEnumerable <Team> teams, DateTime date)
        {
            if (fixtureGenerator == null)
            {
                throw new Exception();
            }

            return(fixtureGenerator.GenerateFixture(teams, date));
        }
Exemplo n.º 4
0
        public IEnumerable <EncounterDTO> CreateFixture(string fixtureGeneratorName, string sportName, DateTime startDate)
        {
            adminValidator.ValidatePermissions();
            ValidateSportIsTwoPlayerSport(sportName);
            IFixtureGenerator       generatorServices = GetFixtureGenerator(fixtureGeneratorName, sportName);
            IEnumerable <Team>      teamsInSport      = teamRepo.GetAll().Where(t => t.Sport.Name == sportName);
            ICollection <Encounter> encounters        = generatorServices.GenerateFixture(teamsInSport, startDate);

            ValidateFixture(encounters);
            SaveEncounters(encounters);
            return(encounters.Select(e => mapper.Map(e)));
        }
Exemplo n.º 5
0
        public JobResult HandleStories(IEnumerable <Story> stories)
        {
            foreach (var story in stories)
            {
                var sourceCode = FixtureGenerator.GenerateFixture(story, _context.GetContextForStory());

                TestFixtureWriter.WriteFixture(story.Id, sourceCode);
            }

            Finished();

            return(GetResult());
        }