Ejemplo n.º 1
0
 public Validator(IArpaContext arpaContext)
 {
     RuleFor(d => d.SectionId)
     .MustAsync(async(dto, sectionId, cancellation) => await arpaContext.SectionAppointments
                .AnyAsync(sa => sa.SectionId == sectionId && sa.AppointmentId == dto.Id, cancellation))
     .WithMessage("The section is not linked to the appointment");
 }
Ejemplo n.º 2
0
 public void Setup()
 {
     _httpContextAccessor = Substitute.For <IHttpContextAccessor>();
     _userManager         = new FakeUserManager();
     _arpaContext         = Substitute.For <IArpaContext>();
     _userAccessor        = new UserAccessor(_httpContextAccessor, _userManager, _arpaContext);
 }
Ejemplo n.º 3
0
 public Handler(
     IArpaContext arpaContext,
     IMapper mapper)
 {
     _arpaContext = arpaContext;
     _mapper      = mapper;
 }
Ejemplo n.º 4
0
        protected override void EnsureDatabaseMigrations(IApplicationBuilder app)
        {
            base.EnsureDatabaseMigrations(app);

            using IServiceScope scope = app.ApplicationServices.CreateScope();
            IServiceProvider services = scope.ServiceProvider;

            try
            {
                ArpaUserManager      userManager   = services.GetRequiredService <ArpaUserManager>();
                SignInManager <User> signInManager = services.GetRequiredService <SignInManager <User> >();
                IArpaContext         arpaContext   = services.GetRequiredService <IArpaContext>();

                if (!IsSeeded)
                {
                    TestSeed.SeedDataAsync(userManager, signInManager, arpaContext).Wait();
                    IsSeeded = true;
                }
            }
            catch (Exception ex)
            {
                ILogger <TestStartup> logger = services.GetRequiredService <ILogger <TestStartup> >();
                logger.LogError(ex, "An error occured during test database migration");
                throw;
            }
        }
Ejemplo n.º 5
0
 public Validator(IArpaContext arpaContext)
 {
     RuleFor(d => d.ProjectId)
     .MustAsync(async(dto, projectId, cancellation) => await arpaContext.ProjectAppointments
                .AnyAsync(pa => pa.AppointmentId == dto.Id && pa.ProjectId == projectId, cancellation))
     .WithMessage("The project is not linked to the appointment");
 }
Ejemplo n.º 6
0
 public Handler(
     IArpaContext arpaContext,
     RoleManager <Role> roleManager)
 {
     _arpaContext = arpaContext;
     _roleManager = roleManager;
 }
Ejemplo n.º 7
0
            public Validator(IArpaContext arpaContext)
            {
                RuleFor(d => d.Id)
                .EntityExists <Command, Project>(arpaContext, nameof(Command.Id));

                RuleFor(d => d.Code)
                .MustAsync(async(dto, code, cancellation) =>
#pragma warning disable RCS1155 // Use StringComparison when comparing strings. -> ToLower() is used to allow ef core to perform the query on db server
                           (!await arpaContext.Projects.AnyAsync(project => dto.Id != project.Id && project.Code.ToLower() == code.ToLower(), cancellation)))
#pragma warning restore RCS1155 // Use StringComparison when comparing strings.
                .WithMessage("The specified project code is already in use. The project code needs to be unique.");

                RuleFor(c => c.ParentId)
                .EntityExists <Command, Project>(arpaContext, nameof(Command.ParentId));


                RuleFor(d => d.StateId)
                .SelectValueMapping <Command, Project>(arpaContext, a => a.State);

                RuleFor(d => d.GenreId)
                .SelectValueMapping <Command, Project>(arpaContext, a => a.Genre);

                RuleFor(d => d.TypeId)
                .SelectValueMapping <Command, Project>(arpaContext, a => a.Type);
            }
Ejemplo n.º 8
0
 public void SetUp()
 {
     _arpaContext = Substitute.For <IArpaContext>();
     _validator   = new Validator(_arpaContext);
     _mockSelectValueCategoryDbSet = MockDbSets.SelectValueCategories;
     _arpaContext.SelectValueCategories.Returns(_mockSelectValueCategoryDbSet);
 }
Ejemplo n.º 9
0
 public Validator(IArpaContext arpaContext)
 {
     RuleFor(d => d.RoomId)
     .MustAsync(async(dto, roomId, cancellation) => await arpaContext.AppointmentRooms
                .AnyAsync(ar => ar.RoomId == roomId && ar.AppointmentId == dto.Id, cancellation))
     .WithMessage("The room is not linked to the appointment");
 }
Ejemplo n.º 10
0
 public Handler(
     IArpaContext context,
     IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Ejemplo n.º 11
0
 public Validator(IArpaContext arpaContext)
 {
     RuleFor(c => c.Name)
     .MustAsync(async(name, cancellation) => !(await arpaContext.Regions
                                               .AnyAsync(r => r.Name == name, cancellation)))
     .WithMessage("A region with the requested name does already exist");
 }
Ejemplo n.º 12
0
 public void SetUp()
 {
     _arpaContext          = Substitute.For <IArpaContext>();
     _mockAppointmentRooms = MockDbSets.AppointmentRooms;
     _arpaContext.AppointmentRooms.Returns(_mockAppointmentRooms);
     _validator          = new Validator(_arpaContext);
     _validAppointmentId = AppointmentSeedData.AfterShowParty.Id;
 }
Ejemplo n.º 13
0
        public void Setup()
        {
            _arpaContext = Substitute.For <IArpaContext>();
            _validator   = new Validator(_arpaContext);
            DbSet <Region> mockRegions = MockDbSets.Regions;

            _arpaContext.Regions.Returns(mockRegions);
        }
Ejemplo n.º 14
0
 public void SetUp()
 {
     _arpaContext        = Substitute.For <IArpaContext>();
     _validator          = new Validator(_arpaContext);
     _validResultId      = SelectValueMappingSeedData.AppointmentParticipationResultMappings[0].Id;
     _validPersonId      = PersonTestSeedData.Performer.Id;
     _validAppointmentId = AppointmentSeedData.RockingXMasRehearsal.Id;
 }
Ejemplo n.º 15
0
            public Validator(IArpaContext arpaContext)
            {
                RuleFor(d => d.Id)
                .EntityExists <Command, Appointment>(arpaContext, nameof(Command.Id));

                RuleFor(d => d.VenueId)
                .EntityExists <Command, Venue>(arpaContext, nameof(Command.VenueId));
            }
Ejemplo n.º 16
0
        public void SetUp()
        {
            _arpaContext      = Substitute.For <IArpaContext>();
            _mockProjectDbSet = MockDbSets.Projects;

            _arpaContext.Projects.Returns(_mockProjectDbSet);
            _validator = new Validator(_arpaContext);
        }
Ejemplo n.º 17
0
 public void SetUp()
 {
     _arpaContext             = Substitute.For <IArpaContext>();
     _mockProjectAppointments = MockDbSets.ProjectAppointments;
     _arpaContext.ProjectAppointments.Returns(_mockProjectAppointments);
     _validator          = new Validator(_arpaContext);
     _validAppointmentId = AppointmentSeedData.RockingXMasRehearsal.Id;
 }
Ejemplo n.º 18
0
        public void Setup()
        {
            _arpaContext = Substitute.For <IArpaContext>();
            DbSet <ProjectParticipation> projectParticipations = MockDbSets.ProjectParticipations;

            _arpaContext.ProjectParticipations.Returns(projectParticipations);
            _handler = new GetForProject.Handler(_arpaContext);
        }
Ejemplo n.º 19
0
 public UserAccessor(
     IHttpContextAccessor httpContextAccessor,
     ArpaUserManager userManager,
     IArpaContext arpaContext) : base(httpContextAccessor)
 {
     _userManager = userManager;
     _arpaContext = arpaContext;
 }
Ejemplo n.º 20
0
 public Validator(IArpaContext arpaContext)
 {
     RuleFor(d => d.Id)
     .EntityExists <Command, Appointment>(arpaContext, nameof(Command.Id));
     RuleFor(d => d.PersonId)
     .EntityExists <Command, Person>(arpaContext, nameof(Command.PersonId));
     RuleFor(d => d.PredictionId)
     .EntityExists <Command, SelectValueMapping>(arpaContext, nameof(Command.PredictionId));
 }
Ejemplo n.º 21
0
 public void SetUp()
 {
     _arpaContext                  = Substitute.For <IArpaContext>();
     _validator                    = new SetProjectParticipation.Validator(_arpaContext);
     _mockProjectDbSet             = MockDbSets.Projects;
     _mockSelectValueCategoryDbSet = MockDbSets.SelectValueCategories;
     _arpaContext.SelectValueCategories.Returns(_mockSelectValueCategoryDbSet);
     _arpaContext.Projects.Returns(_mockProjectDbSet);
 }
Ejemplo n.º 22
0
 public void SetUp()
 {
     _arpaContext             = Substitute.For <IArpaContext>();
     _validator               = new Validator(_arpaContext);
     _validAppointmentId      = AppointmentSeedData.AfterShowParty.Id;
     _validSectionId          = SectionSeedData.LowFemaleVoices.Id;
     _mockSectionAppointments = MockDbSets.SectionAppointments;
     _arpaContext.SectionAppointments.Returns(_mockSectionAppointments);
 }
Ejemplo n.º 23
0
 public static IRuleBuilderOptions <TRequest, Guid> EntityExists <TRequest, TEntity>(
     this IRuleBuilderInitial <TRequest, Guid> ruleBuilderInitial,
     IArpaContext arpaContext,
     string propertyName) where TEntity : BaseEntity
 {
     return(ruleBuilderInitial
            .MustAsync(async(id, cancellation) => (await arpaContext.EntityExistsAsync <TEntity>(id, cancellation)))
            .OnFailure((_) => throw new NotFoundException(typeof(TEntity).Name, propertyName)));
 }
Ejemplo n.º 24
0
 public static IRuleBuilderOptions <TRequest, byte> InstrumentPart <TRequest>(
     this IRuleBuilderInitialCollection <TRequest, byte> ruleBuilderInitial,
     IArpaContext arpaContext) where TRequest : IHasInstrumentRequest
 {
     return(ruleBuilderInitial
            .MustAsync(async(request, preferredPart, cancellation) => (await arpaContext
                                                                       .FindAsync <Section>(new object[] { request.InstrumentId }, cancellation))
                       .InstrumentPartCount >= preferredPart)
            .WithMessage("The selected part is not valid for this instrument"));
 }
Ejemplo n.º 25
0
 public Validator(ArpaUserManager userManager, IArpaContext context)
 {
     RuleFor(c => c.UserName)
     .MustAsync(async(username, cancellation) => await userManager.FindByNameAsync(username) == null)
     .WithMessage("Username aleady exists");
     RuleFor(c => c.Email)
     .MustAsync(async(email, cancellation) => await userManager.FindByEmailAsync(email) == null)
     .WithMessage("Email aleady exists");
     RuleForEach(c => c.StakeholderGroupIds)
     .EntityExists <Command, Section>(context, nameof(Command.StakeholderGroupIds));
 }
Ejemplo n.º 26
0
        public void Setup()
        {
            _arpaContext = Substitute.For <IArpaContext>();
            DbSet <SelectValueCategory> mockSelectValueCategoryDbSet = MockDbSets.SelectValueCategories;

            _arpaContext.SelectValueCategories.Returns(mockSelectValueCategoryDbSet);
            _validator = new SetProjectParticipation.Validator(_arpaContext)
            {
                CascadeMode = FluentValidation.CascadeMode.Stop
            };
        }
Ejemplo n.º 27
0
 public void SetUp()
 {
     _arpaContext          = Substitute.For <IArpaContext>();
     _mapper               = Substitute.For <IMapper>();
     _validator            = new Validator(_arpaContext, _mapper);
     _mockAppointmentDbSet = MockDbSets.Appointments;
     _existingAppointment  = AppointmentSeedData.RockingXMasRehearsal;
     _mockAppointmentDbSet.FindAsync(Arg.Any <Guid>()).Returns(_existingAppointment);
     _arpaContext.Set <Appointment>().Returns(_mockAppointmentDbSet);
     _arpaContext.Appointments.Returns(_mockAppointmentDbSet);
 }
Ejemplo n.º 28
0
 public Handler(
     ArpaUserManager userManager,
     IJwtGenerator jwtGenerator,
     IArpaContext arpaContext,
     IDateTimeProvider dateTimeProvider)
 {
     _userManager      = userManager;
     _arpaContext      = arpaContext;
     _jwtGenerator     = jwtGenerator;
     _dateTimeProvider = dateTimeProvider;
 }
Ejemplo n.º 29
0
            public DoublingInstrumentValidator(IArpaContext arpaContext)
            {
                RuleFor(c => c.AvailabilityId)
                .SelectValueMapping <DoublingInstrumentCommand, MusicianProfileSection>(arpaContext, a => a.InstrumentAvailability);

                RuleFor(c => c.InstrumentId)
                .Must(instrumentId => instrumentId != MainInstrumentId)
                .WithMessage("The doubling instrument may not be the main instrument")
                .MustAsync(async(command, instrumentId, cancellation) => await IsValidDoublingInstrumentAsync(MainInstrumentId, instrumentId, arpaContext, cancellation))
                .WithMessage("This instrument is no valid doubling instrument for the selected main instrument");
            }
Ejemplo n.º 30
0
        public void Setup()
        {
            _arpaContext = Substitute.For <IArpaContext>();
            _validator   = new Validator(_arpaContext);
            DbSet <MusicianProfile> mockMusicianProfiles = MockDbSets.MusicianProfiles;

            _arpaContext.MusicianProfiles.Returns(mockMusicianProfiles);
            _mockSelectValueCategoryDbSet = MockDbSets.SelectValueCategories;
            _arpaContext.SelectValueCategories.Returns(_mockSelectValueCategoryDbSet);
            _mockSectionDbSet = MockDbSets.Sections;
            _arpaContext.Sections.Returns(_mockSectionDbSet);
        }