示例#1
0
        public async Task Should_Get_By_Id(User userToLogin, AppointmentDto expectedDto)
        {
            // Act
            HttpResponseMessage responseMessage = await _authenticatedServer
                                                  .CreateClient()
                                                  .AuthenticateWith(userToLogin)
                                                  .GetAsync(ApiEndpoints.AppointmentsController.Get(expectedDto.Id));

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

            result.Should().BeEquivalentTo(expectedDto);
        }
示例#2
0
        public async Task Should_Remove_Project()
        {
            // Arrange
            AppointmentDto expectedDto = AppointmentDtoData.StaffMeeting;

            expectedDto.Projects.Clear();
            AppointmentParticipationListItemDto performerParticipation = AppointmentDtoData.PerformerParticipation;

            performerParticipation.MusicianProfiles.Add(new ReducedMusicianProfileDto
            {
                Id             = Guid.Parse("e2ef2e6c-035e-4fff-9293-a6a7b67524a9"),
                InstrumentName = "Horn",
                Qualification  = "Student"
            });
            performerParticipation.MusicianProfiles.Add(new ReducedMusicianProfileDto
            {
                Id             = Guid.Parse("056a27f0-cd88-4cd9-8729-ce2f23b8b0ef"),
                InstrumentName = "Tuba"
            });
            performerParticipation.Participation = null;
            expectedDto.Participations.Add(performerParticipation);
            AppointmentParticipationListItemDto staffParticipation = AppointmentDtoData.StaffParticipation;

            staffParticipation.Participation = null;
            expectedDto.Participations.Add(staffParticipation);
            AppointmentParticipationListItemDto adminParticipation = AppointmentDtoData.AdminParticipation;

            expectedDto.Participations.Add(adminParticipation);
            adminParticipation.MusicianProfiles.Add(new ReducedMusicianProfileDto
            {
                Id             = Guid.Parse("9f6f3cab-6b0d-463e-8d66-58b9c760d498"),
                InstrumentName = "Soprano"
            });
            expectedDto.Participations.Add(AppointmentDtoData.WithoutRoleParticipation);

            // Act
            HttpResponseMessage responseMessage = await _authenticatedServer
                                                  .CreateClient()
                                                  .AuthenticateWith(_staff)
                                                  .DeleteAsync(ApiEndpoints.AppointmentsController.Project(
                                                                   AppointmentSeedData.StaffMeeting.Id,
                                                                   ProjectSeedData.HoorayForHollywood.Id));

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

            result.Should().BeEquivalentTo(expectedDto);
        }
示例#3
0
        public void Should_Map()
        {
            // Arrange
            Appointment appointment = FakeAppointments.RockingXMasRehearsal;

            appointment.ProjectAppointments.First().Project.Urls.Remove(appointment.ProjectAppointments.First().Project.Urls.First());
            AppointmentDto expectedDto = AppointmentDtoData.RockingXMasRehearsalForPerformer;

            // Act
            AppointmentDto dto = _mapper.Map <AppointmentDto>(appointment);

            // Assert
            dto.Should().BeEquivalentTo(expectedDto, opt => opt
                                        .Excluding(dto => dto.Participations));
        }
示例#4
0
        public async Task Should_Set_Dates()
        {
            // Arrange
            Appointment appointmentToModify = AppointmentSeedData.PhotoSession;
            var         setDatesDto         = new AppointmentSetDatesBodyDto
            {
                StartTime = FakeDateTime.UtcNow,
                EndTime   = FakeDateTime.UtcNow.AddHours(5)
            };
            AppointmentDto expectedDto = AppointmentDtoData.PhotoSession;

            expectedDto.EndTime    = setDatesDto.EndTime.Value;
            expectedDto.StartTime  = setDatesDto.StartTime.Value;
            expectedDto.ModifiedBy = _staff.DisplayName;
            expectedDto.ModifiedAt = FakeDateTime.UtcNow;
            AppointmentParticipationListItemDto performerParticipation = AppointmentDtoData.PerformerParticipation;

            performerParticipation.Participation = null;
            expectedDto.Participations.Add(performerParticipation);
            AppointmentParticipationListItemDto staffParticipation = AppointmentDtoData.StaffParticipation;

            staffParticipation.Participation = null;
            expectedDto.Participations.Add(staffParticipation);
            AppointmentParticipationListItemDto adminParticipation = AppointmentDtoData.AdminParticipation;

            adminParticipation.MusicianProfiles.Add(new ReducedMusicianProfileDto
            {
                Id             = Guid.Parse("9f6f3cab-6b0d-463e-8d66-58b9c760d498"),
                InstrumentName = SectionSeedData.Soprano.Name
            });
            expectedDto.Participations.Add(adminParticipation);
            expectedDto.Participations.Add(AppointmentDtoData.WithoutRoleParticipation);

            // Act
            HttpResponseMessage responseMessage = await _authenticatedServer
                                                  .CreateClient()
                                                  .AuthenticateWith(_staff)
                                                  .PutAsync(ApiEndpoints.AppointmentsController.SetDates(appointmentToModify.Id), BuildStringContent(setDatesDto));

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

            result.Should().BeEquivalentTo(expectedDto);
        }
示例#5
0
        public async Task Should_Create()
        {
            // Arrange
            var createDto = new AppointmentCreateDto
            {
                Name            = "New Appointment",
                InternalDetails = "Internal Details",
                PublicDetails   = "Public Details",
                EndTime         = new DateTime(2021, 3, 5, 14, 15, 20),
                StartTime       = new DateTime(2021, 3, 5, 9, 15, 20),
                SalaryId        = Guid.Parse("88da1c17-9efc-4f69-ba0f-39c76592845b")
            };

            var expectedDto = new AppointmentDto
            {
                Name            = createDto.Name,
                CreatedBy       = _staff.DisplayName,
                CreatedAt       = FakeDateTime.UtcNow,
                ModifiedAt      = null,
                ModifiedBy      = null,
                InternalDetails = createDto.InternalDetails,
                PublicDetails   = createDto.PublicDetails,
                EndTime         = createDto.EndTime,
                StartTime       = createDto.StartTime,
                StatusId        = createDto.StatusId,
                SalaryId        = createDto.SalaryId
            };

            // Act
            HttpResponseMessage responseMessage = await _authenticatedServer
                                                  .CreateClient()
                                                  .AuthenticateWith(_staff)
                                                  .PostAsync(ApiEndpoints.AppointmentsController.Post(), BuildStringContent(createDto));

            // Assert
            responseMessage.StatusCode.Should().Be(HttpStatusCode.Created);

            AppointmentDto result = await DeserializeResponseMessageAsync <AppointmentDto>(responseMessage);

            result.Should().BeEquivalentTo(expectedDto, opt => opt.Excluding(r => r.Id));
            result.Id.Should().NotBeEmpty();
            responseMessage.Headers.Location.AbsolutePath.Should().Be($"/{ApiEndpoints.AppointmentsController.Get(result.Id)}");
        }
示例#6
0
        public async Task Should_Remove_Section()
        {
            // Arrange
            AppointmentDto expectedDto = AppointmentDtoData.AfterShowPartyForStaff;

            expectedDto.Sections.Clear();

            // Act
            HttpResponseMessage responseMessage = await _authenticatedServer
                                                  .CreateClient()
                                                  .AuthenticateWith(_staff)
                                                  .DeleteAsync(ApiEndpoints.AppointmentsController.Section(
                                                                   AppointmentSeedData.AfterShowParty.Id,
                                                                   SectionSeedData.Alto.Id));

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

            result.Should().BeEquivalentTo(expectedDto);
        }
示例#7
0
        public async Task Should_Add_Project()
        {
            // Arrange
            AppointmentDto expectedDto = AppointmentDtoData.RockingXMasConcert;

            expectedDto.Projects.Add(ProjectDtoData.HoorayForHollywood);

            // Act
            HttpResponseMessage responseMessage = await _authenticatedServer
                                                  .CreateClient()
                                                  .AuthenticateWith(_staff)
                                                  .PostAsync(ApiEndpoints.AppointmentsController.Project(
                                                                 AppointmentSeedData.RockingXMasConcert.Id,
                                                                 ProjectSeedData.HoorayForHollywood.Id), null);

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

            result.Should().BeEquivalentTo(expectedDto);
        }
示例#8
0
        public async Task Should_Add_Section()
        {
            AppointmentDto expectedDto = AppointmentDtoData.RockingXMasRehearsalForStaff;

            expectedDto.Participations.RemoveAt(1);
            expectedDto.Participations.RemoveAt(1); // the second item has already been removed so the third item is on index pos. 1 now
            expectedDto.Sections.Add(SectionDtoData.Alto);

            // Act
            HttpResponseMessage responseMessage = await _authenticatedServer
                                                  .CreateClient()
                                                  .AuthenticateWith(_staff)
                                                  .PostAsync(ApiEndpoints.AppointmentsController.Section(
                                                                 AppointmentSeedData.RockingXMasRehearsal.Id,
                                                                 SectionSeedData.Alto.Id), null);

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

            result.Should().BeEquivalentTo(expectedDto);
        }