Exemple #1
0
        public async Task Success_Accept_Pending_Friend_Invitation()
        {
            await _relationService.RelationInviteAsync(SenderId, TargetId, CharacterRelationType.Friend);

            IEnumerable <RelationInvitationDto> invitations = await _relationService.GetPendingInvitationByCharacterIdAsync(TargetId);

            Assert.IsNotNull(invitations);

            RelationInvitationDto invitation = invitations.FirstOrDefault(s => s.OwnerId == SenderId);

            Assert.IsNotNull(invitation);

            // accept the invitation
            List <RelationDto> relation = await _relationService.RelationInviteProcessAsync(invitation.Id, RelationInvitationProcessType.Accept);

            IEnumerable <RelationDto> relations = await _relationService.GetRelationListByCharacterIdAsync(SenderId);

            Assert.IsTrue(relations.Any(s => s.OwnerId == SenderId && s.TargetId == TargetId && s.Type == CharacterRelationType.Friend && relation.Any(c => c.Id == s.Id)));

            // invitations should be clear
            IEnumerable <RelationInvitationDto> invitationsEmpty = await _relationService.GetPendingInvitationByCharacterIdAsync(TargetId);

            Assert.IsTrue(!invitationsEmpty.Any());

            await _relationService.RelationRemoveAsync(relations);
        }
Exemple #2
0
        protected override async Task Handle(RelationInvitationSendEvent e, CancellationToken cancellation)
        {
            CharacterDto targetCharacter = await _characterService.GetActiveByNameAsync(e.TargetCharacterName);

            await _relationService.RelationInviteAsync(e.Sender.Id, targetCharacter.Id, e.ExpectedRelationType);
        }