Ejemplo n.º 1
0
        public void WhenAgeCriteriaIsApplied_ShouldUseAgeCriteria()
        {
            var ageCriteriaRunners = 2;
            var runners            = _fixture.Build <Runner>()
                                     .With(x => x.Age, 23)
                                     .With(x => x.RaceTime, 90)
                                     .CreateMany(ageCriteriaRunners)
                                     .ToList();

            runners.InsertRange(runners.Count, _fixture
                                .Build <Runner>()
                                .With(x => x.Age, 19)
                                .With(x => x.RaceTime, 150)
                                .CreateMany(1));

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

            _workflowEngine.ApplyTimeCriteria("A", 100, 200);
            _workflowEngine.ApplyAgeCriteria("B", 20, 25);
            _workflowEngine.Distribute();

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

            Assert.Equal(1, corralA.Count);
            Assert.Equal(ageCriteriaRunners, corralB.Count);
        }
Ejemplo n.º 2
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;
            }
        }