示例#1
0
        public void Should_Throw_Exception_When_Link_Does_Not_Exists()
        {
            var linkedParticipant = new LinkedParticipant(_linkedIndividual.Id, Guid.NewGuid(), LinkedParticipantType.Interpreter);

            _individual.Invoking(x => x.RemoveLink(linkedParticipant)).Should()
            .Throw <DomainRuleException>();
        }
示例#2
0
        public Task CreateParticipantLinks(List <Participant> participants, List <LinkedParticipantDto> linkedParticipantDtos)
        {
            var linkedParticipants = new List <LinkedParticipant>();

            foreach (var linkedParticipantDto in linkedParticipantDtos)
            {
                var interpretee =
                    participants.Single(x =>
                                        x.Person.ContactEmail.Equals(linkedParticipantDto.ParticipantContactEmail,
                                                                     StringComparison.CurrentCultureIgnoreCase));
                var interpreter =
                    participants.Single(x =>
                                        x.Person.ContactEmail.Equals(linkedParticipantDto.LinkedParticipantContactEmail,
                                                                     StringComparison.CurrentCultureIgnoreCase));

                var linkedParticipant = new LinkedParticipant(interpretee.Id, interpreter.Id,
                                                              linkedParticipantDto.Type);

                linkedParticipants.Add(linkedParticipant);

                UpdateParticipantsWithLinks(interpretee, interpreter, linkedParticipantDto.Type);
            }

            return(Task.FromResult(linkedParticipants));
        }
 public static LinkedParticipantResponse MapLinkedParticipantsToResponse(LinkedParticipant linkedParticipant)
 {
     return(new LinkedParticipantResponse()
     {
         Type = linkedParticipant.Type.MapToContractEnum(),
         LinkedId = linkedParticipant.LinkedId
     });
 }
示例#4
0
 public static LinkedParticipantDto MapToDto(LinkedParticipant linkedParticipant)
 {
     return(new LinkedParticipantDto
     {
         ParticipantId = linkedParticipant.ParticipantId,
         LinkedId = linkedParticipant.LinkedId,
         Type = linkedParticipant.Type
     });
 }
示例#5
0
        public void should_map_all_properties()
        {
            var linkedParticipant =
                new LinkedParticipant(Guid.NewGuid(), Guid.NewGuid(), LinkedParticipantType.Interpreter);

            var response = LinkedParticipantToResponseMapper.MapLinkedParticipantsToResponse(linkedParticipant);

            response.LinkedId.Should().Be(linkedParticipant.LinkedId);
            response.Type.Should().Be(linkedParticipant.Type);
        }
示例#6
0
        public void RemoveLink(LinkedParticipant linkedParticipant)
        {
            var link = LinkedParticipants.SingleOrDefault(
                x => x.LinkedId == linkedParticipant.LinkedId && x.Type == linkedParticipant.Type);

            if (link == null)
            {
                throw new DomainRuleException("LinkedParticipant", "Link does not exist");
            }

            LinkedParticipants.Remove(linkedParticipant);
        }
        private bool HasExistingLink(LinkedParticipant linkedParticipantInRequest, ParticipantResponse participant)
        {
            var linkedId     = linkedParticipantInRequest.LinkedId;
            var existingLink = false;

            if (participant.LinkedParticipants != null)
            {
                existingLink = participant.LinkedParticipants.Exists(x => x.LinkedId == linkedId);
            }

            return(existingLink);
        }
示例#8
0
 public void SetUp()
 {
     _linkedParticipant = BuildLinkedParticipant();
 }