예제 #1
0
        private void ConfigureCorralCriteria(string selectedCorral, string selectedCriteria)
        {
            switch (selectedCriteria)
            {
            case "1":
                Console.WriteLine($"Age criteria for Corral {selectedCorral}.");
                Console.WriteLine("Input minimum age: ");
                var minAge = ReadIntegerFromConsole();
                Console.WriteLine("Input maximum age: ");
                var maxAge = ReadIntegerFromConsole();
                workflowEngine.ApplyAgeCriteria(selectedCorral, minAge, maxAge);
                break;

            case "2":
                Console.WriteLine($"Race Time criteria for Corral {selectedCorral}.");
                Console.WriteLine("Input minimum Time: ");
                var minTime = ReadIntegerFromConsole();
                Console.WriteLine("Input maximum Time: ");
                var maxTime = ReadIntegerFromConsole();
                workflowEngine.ApplyTimeCriteria(selectedCorral, minTime, maxTime);
                break;

            case "3":
                Console.WriteLine($"Gender criteria for Corral {selectedCorral}.");
                Console.WriteLine("Input Gender [M]ale/[F]emale: ");
                Gender gender = ReadGenderFromConsole();
                workflowEngine.ApplyGenderCriteria(selectedCorral, gender);
                break;

            default:
                Console.Error.WriteLine("Invalid Criteria");
                break;
            }
        }
예제 #2
0
        public void WhenGenderCriteriaIsApplied_ShouldUseAgeCriteria()
        {
            var genderCriteriaRunners = 40;
            var runners = _fixture.Build <Runner>()
                          .With(x => x.Gender, Gender.Female)
                          .CreateMany(genderCriteriaRunners)
                          .ToList();

            runners.InsertRange(runners.Count, _fixture
                                .Build <Runner>()
                                .With(x => x.Gender, Gender.Male)
                                .CreateMany(3000));

            _runnerGeneratorMock.Setup(x => x.Generate(It.IsAny <int>()))
            .Returns(runners);

            _workflowEngine.ApplyGenderCriteria("A", Gender.Female);

            _workflowEngine.Distribute();

            var corralA = _workflowEngine.Corrals.Single(x => x.Name == "A");
            var corralB = _workflowEngine.Corrals.Single(x => x.Name == "B");
            var corralC = _workflowEngine.Corrals.Single(x => x.Name == "C");

            Assert.Equal(genderCriteriaRunners, corralA.Count);
            Assert.Equal(corralB.MaxElements, corralB.Count);
            Assert.Equal(corralC.MaxElements, corralC.Count);
        }