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"); }
public void Setup() { _httpContextAccessor = Substitute.For <IHttpContextAccessor>(); _userManager = new FakeUserManager(); _arpaContext = Substitute.For <IArpaContext>(); _userAccessor = new UserAccessor(_httpContextAccessor, _userManager, _arpaContext); }
public Handler( IArpaContext arpaContext, IMapper mapper) { _arpaContext = arpaContext; _mapper = mapper; }
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; } }
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"); }
public Handler( IArpaContext arpaContext, RoleManager <Role> roleManager) { _arpaContext = arpaContext; _roleManager = roleManager; }
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); }
public void SetUp() { _arpaContext = Substitute.For <IArpaContext>(); _validator = new Validator(_arpaContext); _mockSelectValueCategoryDbSet = MockDbSets.SelectValueCategories; _arpaContext.SelectValueCategories.Returns(_mockSelectValueCategoryDbSet); }
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"); }
public Handler( IArpaContext context, IMapper mapper) { _context = context; _mapper = mapper; }
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"); }
public void SetUp() { _arpaContext = Substitute.For <IArpaContext>(); _mockAppointmentRooms = MockDbSets.AppointmentRooms; _arpaContext.AppointmentRooms.Returns(_mockAppointmentRooms); _validator = new Validator(_arpaContext); _validAppointmentId = AppointmentSeedData.AfterShowParty.Id; }
public void Setup() { _arpaContext = Substitute.For <IArpaContext>(); _validator = new Validator(_arpaContext); DbSet <Region> mockRegions = MockDbSets.Regions; _arpaContext.Regions.Returns(mockRegions); }
public void SetUp() { _arpaContext = Substitute.For <IArpaContext>(); _validator = new Validator(_arpaContext); _validResultId = SelectValueMappingSeedData.AppointmentParticipationResultMappings[0].Id; _validPersonId = PersonTestSeedData.Performer.Id; _validAppointmentId = AppointmentSeedData.RockingXMasRehearsal.Id; }
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)); }
public void SetUp() { _arpaContext = Substitute.For <IArpaContext>(); _mockProjectDbSet = MockDbSets.Projects; _arpaContext.Projects.Returns(_mockProjectDbSet); _validator = new Validator(_arpaContext); }
public void SetUp() { _arpaContext = Substitute.For <IArpaContext>(); _mockProjectAppointments = MockDbSets.ProjectAppointments; _arpaContext.ProjectAppointments.Returns(_mockProjectAppointments); _validator = new Validator(_arpaContext); _validAppointmentId = AppointmentSeedData.RockingXMasRehearsal.Id; }
public void Setup() { _arpaContext = Substitute.For <IArpaContext>(); DbSet <ProjectParticipation> projectParticipations = MockDbSets.ProjectParticipations; _arpaContext.ProjectParticipations.Returns(projectParticipations); _handler = new GetForProject.Handler(_arpaContext); }
public UserAccessor( IHttpContextAccessor httpContextAccessor, ArpaUserManager userManager, IArpaContext arpaContext) : base(httpContextAccessor) { _userManager = userManager; _arpaContext = arpaContext; }
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)); }
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); }
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); }
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))); }
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")); }
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)); }
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 }; }
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); }
public Handler( ArpaUserManager userManager, IJwtGenerator jwtGenerator, IArpaContext arpaContext, IDateTimeProvider dateTimeProvider) { _userManager = userManager; _arpaContext = arpaContext; _jwtGenerator = jwtGenerator; _dateTimeProvider = dateTimeProvider; }
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"); }
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); }