public async Task GenerateScheduleShouldHaveParticipantCountGamesPerRound(int roundCount, int participantCount, IEnumerable <List <int> > mockedSeed) { _cyclicSeedGeneratorMock.Setup(generator => generator.GenerateSeed(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(mockedSeed); RoundRobinSchedule result = await _cyclicGenerator.GenerateSchedule(roundCount, participantCount); result.Rounds.Should().OnlyContain(r => r.Games.Count() == participantCount / 4); }
public async Task GenerateScheduleShouldHaveRoundCountRounds(int roundCount, int participantCount, IEnumerable <List <int> > mockedSeed) { _cyclicSeedGeneratorMock.Setup(generator => generator.GenerateSeed(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(mockedSeed); RoundRobinSchedule result = await _cyclicGenerator.GenerateSchedule(roundCount, participantCount); result.Rounds.Should().HaveCount(roundCount); }
public async Task GenerateScheduleShouldCallCyclicSeedGenerator(int roundCount, int participantCount, IEnumerable <List <int> > mockedSeed) { _cyclicSeedGeneratorMock.Setup(generator => generator.GenerateSeed(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(mockedSeed); RoundRobinSchedule result = await _cyclicGenerator.GenerateSchedule(roundCount, participantCount); _cyclicSeedGeneratorMock.Verify(generator => generator.GenerateSeed(roundCount, participantCount / 4), Times.Once); }
public async Task GenerateScheduleShouldHaveUniquePairs(int roundCount, int participantCount, IEnumerable <List <int> > mockedSeed) { _cyclicSeedGeneratorMock.Setup(generator => generator.GenerateSeed(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(mockedSeed); RoundRobinSchedule result = await _cyclicGenerator.GenerateSchedule(roundCount, participantCount); result.Rounds.SelectMany(r => r.Games.SelectMany(g => Pairs(g.ParticipantNrs))).Should() .OnlyHaveUniqueItems(); }
public async Task GenerateScheduleShouldHaveIncreasingParticipantsPerGame(int roundCount, int participantCount, IEnumerable <List <int> > mockedSeed) { _cyclicSeedGeneratorMock.Setup(generator => generator.GenerateSeed(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(mockedSeed); RoundRobinSchedule result = await _cyclicGenerator.GenerateSchedule(roundCount, participantCount); result.Rounds.SelectMany(r => r.Games).Should() .OnlyContain(g => g.ParticipantNrs.SequenceEqual(g.ParticipantNrs.OrderBy(x => x))); }
public async Task GenerateScheduleShouldHaveAllParticipantsPerRound(int roundCount, int participantCount, IEnumerable <List <int> > mockedSeed) { _cyclicSeedGeneratorMock.Setup(generator => generator.GenerateSeed(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(mockedSeed); RoundRobinSchedule result = await _cyclicGenerator.GenerateSchedule(roundCount, participantCount); using AssertionScope assertionScope = new AssertionScope(); foreach (var round in result.Rounds) { round.Games.SelectMany(g => g.ParticipantNrs).Should() .OnlyHaveUniqueItems() .And.BeEquivalentTo(Enumerable.Range(0, participantCount)); } }