Exemple #1
0
        public void Should_Map()
        {
            // Arrange
            MusicianProfile    musicianProfile = FakeMusicianProfiles.PerformerHornMusicianProfile;
            MusicianProfileDto expectedDto     = MusicianProfileDtoData.PerformersHornMusicianProfile;

            // Act
            MusicianProfileDto mappedDto = _mapper.Map <MusicianProfileDto>(musicianProfile);

            // Assert
            mappedDto.Should().BeEquivalentTo(expectedDto);
        }
Exemple #2
0
        public async Task Should_Get_My_MusicianProfile_ById()
        {
            // Arrange
            MyMusicianProfileDto expectedDto = MyMusicianProfileDtoData.PerformerProfile;

            // Act
            HttpResponseMessage responseMessage = await _authenticatedServer
                                                  .CreateClient()
                                                  .AuthenticateWith(_performer)
                                                  .GetAsync(ApiEndpoints.MyMusicianProfilesController.GetById(expectedDto.Id));

            // Assert
            responseMessage.StatusCode.Should().Be(HttpStatusCode.OK);
            MusicianProfileDto result = await DeserializeResponseMessageAsync <MusicianProfileDto>(responseMessage);

            result.Should().BeEquivalentTo(expectedDto);
        }
Exemple #3
0
        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)}");
        }
Exemple #4
0
        public async Task <ActionResult <MusicianProfileDto> > AddMusicianProfile(MusicianProfileCreateDto musicianProfileCreateDto)
        {
            MusicianProfileDto createdMusicianProfile = await _musicianProfileService.CreateAsync(musicianProfileCreateDto);

            return(CreatedAtAction(nameof(MusicianProfilesController.GetById), "MusicianProfiles", new { id = createdMusicianProfile.Id }, createdMusicianProfile));
        }