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_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 void Should_add_new_participant_to_hearing() { var conference = new ConferenceBuilder().Build(); var beforeCount = conference.GetParticipants().Count; var participant = new ParticipantBuilder().Build(); conference.AddParticipant(participant); var afterCount = conference.GetParticipants().Count; afterCount.Should().BeGreaterThan(beforeCount); }
public async Task Should_remove_participant_from_conference_and_remove_links_to_other_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(); 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); var seededConference = await TestDataManager.SeedConference(conference); TestContext.WriteLine($"New seeded conference id: {seededConference.Id}"); _newConferenceId = seededConference.Id; var beforeCount = seededConference.GetParticipants().Count; var participantToRemove = seededConference.GetParticipants().First(); var participants = new List <Participant> { participantToRemove }; var command = new RemoveParticipantsFromConferenceCommand(_newConferenceId, participants); await _handler.Handle(command); var updatedConference = await _conferenceByIdHandler.Handle(new GetConferenceByIdQuery(_newConferenceId)); var confParticipants = updatedConference.GetParticipants(); confParticipants.Any(x => x.Username == participantToRemove.Username).Should().BeFalse(); confParticipants.Any(x => x.LinkedParticipants.Any()).Should().BeFalse(); var afterCount = updatedConference.GetParticipants().Count; afterCount.Should().BeLessThan(beforeCount); }
public void Should_not_add_existing_participant_to_hearing() { var conference = new ConferenceBuilder() .WithParticipant(UserRole.Individual, "Claimant") .WithParticipant(UserRole.Representative, "Claimant") .WithParticipant(UserRole.Representative, "Defendant") .WithParticipant(UserRole.Individual, "Defendant") .Build(); var beforeCount = conference.GetParticipants().Count; var participant = conference.GetParticipants().First(); Action action = () => conference.AddParticipant(participant); action.Should().Throw <DomainRuleException>(); var afterCount = conference.GetParticipants().Count; afterCount.Should().Be(beforeCount); }