Esempio n. 1
0
        static void Main(string[] args)
        {
            var                globalStorage     = GlobalStorage.Instance;
            IFileService       fileService       = new FileService(globalStorage);
            IAllocationService allocationService = new AllocationService(globalStorage);
            IPromotionService  promotionService  = new PromotionService(globalStorage);
            IBalanceService    balanceService    = new BalanceService(globalStorage);
            IConsoleService    consoleService    = new ConsoleService();

            consoleService.ShowInitialInformation();

            var option = string.Empty;

            while (option != Commands.exit)
            {
                var optionSplit = GetConsoleParameters();

                option = optionSplit[0];
                try
                {
                    switch (option)
                    {
                    case Commands.allocate:
                        globalStorage.Teams = allocationService.Allocate(globalStorage.Teams, globalStorage.EmployeesFromFile);
                        consoleService.ShowTeamsAndEmployees(globalStorage.Teams);
                        break;

                    case Commands.balance:
                        globalStorage.Teams = balanceService.BalanceTeams(globalStorage.Teams);
                        consoleService.ShowTeamsAndEmployees(globalStorage.Teams);
                        break;

                    case Commands.load:
                        globalStorage.Teams             = fileService.LoadFileTeam(optionSplit.ElementAtOrDefault(1));
                        globalStorage.EmployeesFromFile = fileService.LoadFileEmployee(optionSplit.ElementAtOrDefault(2));
                        Console.WriteLine(Messages.MSG002);
                        break;

                    case Commands.promote:
                        promotionService.Promote(optionSplit.ElementAtOrDefault(1));
                        break;

                    case Commands.showTeams:
                        consoleService.ShowTeamsAndEmployeesDetail(globalStorage.Teams);
                        break;

                    case Commands.exit:
                        break;

                    default:
                        Console.WriteLine(Messages.MSG001);
                        break;
                    }
                }
                catch (BusinessException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Esempio n. 2
0
        public void AllocateTests(int businessSeats, int economySeats, AllocateResult expected)
        {
            // Arrange
            var offers            = new[] { 374, 209, 155, 115, 101, 100, 99, 45, 23, 22 };
            var spec              = new AllocateSpec(offers, businessSeats, economySeats, 100);
            var allocationService = new AllocationService();
            var comparer          = new UsageEqualityComparer();

            // Act
            var actual = allocationService.Allocate(spec);

            // Assert
            Assert.Equal(actual.BusinessUsage, expected.BusinessUsage, comparer);
            Assert.Equal(actual.EconomyUsage, expected.EconomyUsage, comparer);
        }