Example #1
0
        public void Init()
        {
            var dataMocks = new DebRegDataMocks();
            IUnitOfWork unitOfWork = dataMocks.UnitOfWork;
            ISlotAssignmentManager slotAssignmentManager = new SlotAssignmentManager(unitOfWork);
            IBookingManager bookingManager = new BookingManager(unitOfWork);

            DebRegUserManager userManager = dataMocks.UserManager;
            ITournamentManager tournamentManager = new TournamentManager(unitOfWork, userManager);

            var communiationMocks = new DebRegCommunicationMocks();
            IEMailService emailService = communiationMocks.EMailService;
            ITournamentRegistrationsManager tournamentRegistrationsManager = new TournamentRegistrationsManager(unitOfWork, emailService, userManager);
            ISlotManager slotManager = new SlotManager(slotAssignmentManager, tournamentRegistrationsManager, tournamentManager, bookingManager, emailService, userManager);

            SecurityMocks securityMocks = new SecurityMocks();
            IAuthenticationManager authManager = securityMocks.AuthManager;
            ISecurityManager securityManager = new SecurityManager(userManager, authManager);
            IOrganizationManager organizationManager = new OrganizationManager(unitOfWork, userManager);
            SlotController slotController = new SlotController(
                unitOfWork, 
                tournamentRegistrationsManager, 
                slotAssignmentManager, 
                slotManager, 
                organizationManager, 
                tournamentManager,
                userManager);
        }
Example #2
0
        public void Init()
        {
            // Create mocks
            DebRegDataMocks dataMocks = new DebRegDataMocks();
            DebRegCommunicationMocks communicationMocks = new DebRegCommunicationMocks();
            userManager = dataMocks.UserManager;

            unitOfWork = dataMocks.UnitOfWork;
            // Create Managers
            slotAssignmentManager = new SlotAssignmentManager(unitOfWork);
            tournamentManager = new TournamentManager(unitOfWork, userManager);
            tournamentRegistrationsManager = new TournamentRegistrationsManager(unitOfWork, communicationMocks.EMailService, userManager);
            bookingManager = new BookingManager(unitOfWork);

            slotManager = new SlotManager(slotAssignmentManager, tournamentRegistrationsManager, tournamentManager, bookingManager, communicationMocks.EMailService, userManager);

            // Create basic objects

            Organization hostingOrganization = new Organization { Id = Guid.NewGuid() };
            Random rand = new Random();

            User user = CreateUserWithOrganizationRole(hostingOrganization, OrganizationRole.OrganizationTournamentManager);

            // Create tournament

            tournament = new Tournament
            {
                Id = Guid.NewGuid(),
                HostingOrganization = hostingOrganization,
                HostingOrganizationID = hostingOrganization.Id,
                TeamProduct = new Product
                {
                    Id = Guid.NewGuid(),
                    Price = 40
                },
                AdjudicatorProduct = new Product
                {
                    Id = Guid.NewGuid(),
                    Price = 20
                }
            };
            {
                var task = tournamentManager.AddTournamentAsync(tournament, user);
                if (!task.IsCompleted)
                {
                    task.Wait();
                }
            }

            // Create registrations
            Guid[] organizationIds = new Guid[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };

            for (int i = 0; i < organizationIds.Length; i++)
            {
                int teamsWanted = i + 1;
                int adjudicatorsWanted = i;
                var registration = tournamentRegistrationsManager.AddRegistration(
                    tournament.Id,
                    organizationIds[i],
                    organizationIds[i],
                    teamsWanted,
                    adjudicatorsWanted,
                    null,
                    user
                );

                registration.OrganizationStatus = OrganizationStatus.Approved;
                registration.OrganizationStatusDraft = false;
            }

        }