public async Task Should_Not_Add_MusicianProfile_Due_To_Missing_Mandatory_Field() { // Arrange var createDto = new MusicianProfileCreateBodyDto { InstrumentId = SectionSeedData.Euphonium.Id, // -> this is the missing mandatory field: QualificationId }; // Act HttpResponseMessage responseMessage = await _authenticatedServer .CreateClient() .AuthenticateWith(_staff) .PostAsync(ApiEndpoints.PersonsController.AddMusicianProfile(FakePersons.Performer.Id), BuildStringContent(createDto)); // Assert responseMessage.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); }
public async Task Should_Add_MusicianProfile() { // Arrange var createDto = new MusicianProfileCreateBodyDto { InstrumentId = SectionSeedData.Clarinet.Id, QualificationId = SelectValueMappingSeedData.MusicianProfileQualificationMappings[2].Id, }; createDto.PreferredPositionsInnerIds.Add(SelectValueSectionSeedData.ClarinetCoach.Id); createDto.PreferredPositionsTeamIds.Add(SelectValueSectionSeedData.ClarinetSolo.Id); createDto.PreferredPartsInner.Add(2); createDto.PreferredPartsInner.Add(4); createDto.PreferredPartsTeam.Add(1); var createDoublingInstrumentDto = new DoublingInstrumentCreateDto { InstrumentId = SectionSeedData.EbClarinet.Id, AvailabilityId = SelectValueMappingSeedData.MusicianProfileSectionInstrumentAvailabilityMappings[0].Id, LevelAssessmentTeam = 3, LevelAssessmentInner = 4, Comment = "my comment" }; createDto.DoublingInstruments.Add(createDoublingInstrumentDto); var expectedDto = new MusicianProfileDto { InstrumentId = createDto.InstrumentId, QualificationId = createDto.QualificationId, PersonId = PersonDtoData.LockedOutUser.Id, CreatedBy = _staff.DisplayName, CreatedAt = FakeDateTime.UtcNow, IsMainProfile = true }; expectedDto.PreferredPositionsInnerIds.Add(SelectValueSectionSeedData.ClarinetCoach.Id); expectedDto.PreferredPositionsTeamIds.Add(SelectValueSectionSeedData.ClarinetSolo.Id); expectedDto.PreferredPartsInner.Add(2); expectedDto.PreferredPartsInner.Add(4); expectedDto.PreferredPartsTeam.Add(1); expectedDto.DoublingInstruments.Add(new DoublingInstrumentDto { AvailabilityId = createDoublingInstrumentDto.AvailabilityId, Comment = createDoublingInstrumentDto.Comment, InstrumentId = createDoublingInstrumentDto.InstrumentId, LevelAssessmentTeam = createDoublingInstrumentDto.LevelAssessmentTeam, CreatedAt = FakeDateTime.UtcNow, CreatedBy = _staff.DisplayName, LevelAssessmentInner = createDoublingInstrumentDto.LevelAssessmentInner }); // Act HttpResponseMessage responseMessage = await _authenticatedServer .CreateClient() .AuthenticateWith(_staff) .PostAsync(ApiEndpoints.PersonsController.AddMusicianProfile(PersonDtoData.LockedOutUser.Id), BuildStringContent(createDto)); // Assert responseMessage.StatusCode.Should().Be(HttpStatusCode.Created); MusicianProfileDto result = await DeserializeResponseMessageAsync <MusicianProfileDto>(responseMessage); result.Should().BeEquivalentTo(expectedDto, opt => opt.Excluding(r => r.Id).Excluding(r => r.DoublingInstruments)); result.Id.Should().NotBeEmpty(); result.DoublingInstruments.Count.Should().Be(1); result.DoublingInstruments.First().Should().BeEquivalentTo(expectedDto.DoublingInstruments.First(), opt => opt.Excluding(dto => dto.Id)); result.DoublingInstruments.First().Id.Should().NotBeEmpty(); responseMessage.Headers.Location.AbsolutePath.Should().Be($"/{ApiEndpoints.MusicianProfilesController.Get(result.Id)}"); }