public async Task Should_update_participant_username_when_provided() { var seededConference = await TestDataManager.SeedConference(); TestContext.WriteLine($"New seeded conference id: {seededConference.Id}"); _newConferenceId = seededConference.Id; var participant = seededConference.GetParticipants().First(); var command = new UpdateParticipantDetailsCommand(_newConferenceId, participant.Id, "fullname", "firstName", "lastName", "displayname", String.Empty, "*****@*****.**", "0123456789", new List <LinkedParticipantDto>()) { Username = "******" }; await _handler.Handle(command); var updatedConference = await _conferenceByIdHandler.Handle(new GetConferenceByIdQuery(_newConferenceId)); var updatedParticipant = updatedConference.GetParticipants().Single(x => x.Id == participant.Id); updatedParticipant.DisplayName.Should().Be("displayname"); updatedParticipant.Name.Should().Be("fullname"); updatedParticipant.FirstName.Should().Be("firstName"); updatedParticipant.LastName.Should().Be("lastName"); updatedParticipant.ContactEmail.Should().Be("*****@*****.**"); updatedParticipant.ContactTelephone.Should().Be("0123456789"); updatedParticipant.Username.Should().Be(command.Username); }
public async Task <IActionResult> UpdateParticipantDetailsAsync(Guid conferenceId, Guid participantId, UpdateParticipantRequest request) { _logger.LogDebug("UpdateParticipantDetails"); try { var linkedParticipants = request.LinkedParticipants.Select(x => new LinkedParticipantDto() { ParticipantRefId = x.ParticipantRefId, LinkedRefId = x.LinkedRefId, Type = x.Type.MapToDomainEnum() }).ToList(); var updateParticipantDetailsCommand = new UpdateParticipantDetailsCommand(conferenceId, participantId, request.Fullname, request.FirstName, request.LastName, request.DisplayName, request.Representee, request.ContactEmail, request.ContactTelephone, linkedParticipants); if (!request.Username.IsNullOrEmpty()) { updateParticipantDetailsCommand.Username = request.Username; } await _commandHandler.Handle(updateParticipantDetailsCommand); return(NoContent()); } catch (ConferenceNotFoundException ex) { _logger.LogError(ex, "Unable to find conference"); return(NotFound()); } catch (ParticipantNotFoundException ex) { _logger.LogError(ex, "Unable to find participant"); return(NotFound()); } }
public void Should_throw_conference_not_found_exception_when_conference_does_not_exist() { var conferenceId = Guid.NewGuid(); var participantId = Guid.NewGuid(); var command = new UpdateParticipantDetailsCommand(conferenceId, participantId, "fullname", "firstName", "lastName", "displayname", String.Empty, "*****@*****.**", "1234"); Assert.ThrowsAsync <ConferenceNotFoundException>(() => _handler.Handle(command)); }
public async Task Should_update_participant_details_and_linked_participants() { var conference = new ConferenceBuilder(true, null, DateTime.UtcNow.AddMinutes(5)) .WithConferenceStatus(ConferenceState.InSession) .Build(); var participantA = new ParticipantBuilder(true).Build(); var participantB = new ParticipantBuilder(true).Build(); var participantC = new ParticipantBuilder(true).Build(); participantA.LinkedParticipants.Add(new LinkedParticipant(participantA.Id, participantB.Id, LinkedParticipantType.Interpreter)); participantB.LinkedParticipants.Add(new LinkedParticipant(participantB.Id, participantA.Id, LinkedParticipantType.Interpreter)); conference.AddParticipant(participantA); conference.AddParticipant(participantB); conference.Participants.Add(participantC); var seededConference = await TestDataManager.SeedConference(conference); TestContext.WriteLine($"New seeded conference id: {seededConference.Id}"); _newConferenceId = seededConference.Id; var participant = seededConference.GetParticipants().First(); var newLinkedParticipants = new List <LinkedParticipantDto>() { new LinkedParticipantDto() { ParticipantRefId = participantC.ParticipantRefId, LinkedRefId = participantA.ParticipantRefId, Type = LinkedParticipantType.Interpreter }, new LinkedParticipantDto() { ParticipantRefId = participantA.ParticipantRefId, LinkedRefId = participantC.ParticipantRefId, Type = LinkedParticipantType.Interpreter } }; var command = new UpdateParticipantDetailsCommand(_newConferenceId, participant.Id, "fullname", "firstName", "lastName", "displayname", String.Empty, "*****@*****.**", "0123456789", newLinkedParticipants); await _handler.Handle(command); var updatedConference = await _conferenceByIdHandler.Handle(new GetConferenceByIdQuery(_newConferenceId)); var updatedParticipant = updatedConference.GetParticipants().Single(x => x.Username == participant.Username); updatedParticipant.LinkedParticipants.Should().NotContain(x => x.LinkedId == participantB.Id); updatedParticipant.LinkedParticipants.Should().Contain(x => x.LinkedId == participantC.Id); }
public async Task Should_throw_participant_not_found_exception_when_participant_does_not_exist() { var seededConference = await TestDataManager.SeedConference(); TestContext.WriteLine($"New seeded conference id: {seededConference.Id}"); _newConferenceId = seededConference.Id; var participantId = Guid.NewGuid(); var command = new UpdateParticipantDetailsCommand(_newConferenceId, participantId, "fullname", "firstName", "lastName", "displayname", String.Empty, "*****@*****.**", "1234"); Assert.ThrowsAsync <ParticipantNotFoundException>(() => _handler.Handle(command)); }
public async Task Should_throw_participant_link_exception_when_id_doesnt_match() { var conference = new ConferenceBuilder(true, null, DateTime.UtcNow.AddMinutes(5)) .WithConferenceStatus(ConferenceState.InSession) .Build(); var participantA = new ParticipantBuilder(true).Build(); var participantB = new ParticipantBuilder(true).Build(); var participantC = new ParticipantBuilder(true).Build(); participantA.LinkedParticipants.Add(new LinkedParticipant(participantA.Id, participantB.Id, LinkedParticipantType.Interpreter)); participantB.LinkedParticipants.Add(new LinkedParticipant(participantB.Id, participantA.Id, LinkedParticipantType.Interpreter)); conference.AddParticipant(participantA); conference.AddParticipant(participantB); conference.Participants.Add(participantC); var seededConference = await TestDataManager.SeedConference(conference); TestContext.WriteLine($"New seeded conference id: {seededConference.Id}"); _newConferenceId = seededConference.Id; var participant = seededConference.GetParticipants().First(); var fakeIdA = Guid.NewGuid(); var fakeIdC = Guid.NewGuid(); var newLinkedParticipants = new List <LinkedParticipantDto>() { new LinkedParticipantDto() { ParticipantRefId = fakeIdC, LinkedRefId = participantA.ParticipantRefId, Type = LinkedParticipantType.Interpreter }, new LinkedParticipantDto() { ParticipantRefId = fakeIdA, LinkedRefId = participantC.ParticipantRefId, Type = LinkedParticipantType.Interpreter } }; var command = new UpdateParticipantDetailsCommand(_newConferenceId, participant.Id, "fullname", "firstName", "lastName", "displayname", String.Empty, "*****@*****.**", "0123456789", newLinkedParticipants); var exception = Assert.ThrowsAsync <ParticipantLinkException>(() => _handler.Handle(command)); exception.LinkRefId.Should().Be(participantA.ParticipantRefId); exception.ParticipantRefId.Should().Be(fakeIdC); }
public async Task <IActionResult> UpdateParticipantDetailsAsync(Guid conferenceId, Guid participantId, UpdateParticipantRequest request) { _logger.LogDebug("UpdateParticipantDetails"); try { var updateParticipantDetailsCommand = new UpdateParticipantDetailsCommand(conferenceId, participantId, request.Fullname, request.FirstName, request.LastName, request.DisplayName, request.Representee, request.ContactEmail, request.ContactTelephone); await _commandHandler.Handle(updateParticipantDetailsCommand); return(NoContent()); } catch (ConferenceNotFoundException ex) { _logger.LogError(ex, "Unable to find conference"); return(NotFound()); } catch (ParticipantNotFoundException ex) { _logger.LogError(ex, "Unable to find participant"); return(NotFound()); } }