Beispiel #1
0
        public static ChannelMemberResponse ToChannelMemberResponse(this ChannelMembers channelMember)
        {
            var channelMemberResponse = new ChannelMemberResponse();

            if (channelMember != null)
            {
                channelMemberResponse.MemberId          = channelMember.MemberId;
                channelMemberResponse.ChannelId         = channelMember.ChannelId;
                channelMemberResponse.IsMuted           = channelMember.IsMuted;
                channelMemberResponse.LastReadMessageId = channelMember.LastReadMessageId;
            }
            return(channelMemberResponse);
        }
        public async Task ShouldReturnChannelMemberResponsesCollection()
        {
            // Arrange
            var channelId = new Guid("EFBDF9F0-1E51-4EBC-89F3-D31FFA88F659");

            _channelRepositoryMock.Setup(x => x.IsChannelExistsAsync(It.IsAny <Guid>()))
            .ReturnsAsync(true)
            .Verifiable();

            var channelMembers = new List <ChannelMember>
            {
                new ChannelMember {
                    ChannelId = new Guid("634181BE-924F-4ED3-AF9E-CAA8FEC53A57")
                }
            };

            _channelMemberRepositoryMock.Setup(x => x.GetChannelMembersAsync(It.Is <Guid>(id => id.Equals(channelId))))
            .ReturnsAsync(channelMembers)
            .Verifiable();

            var channelMemberResponses = new List <ChannelMemberResponse>();

            foreach (var channelMember in channelMembers)
            {
                var channelMemberResponse = new ChannelMemberResponse();
                _domainModelsMapperMock.Setup(x => x.MapToChannelMemberResponse(It.Is <ChannelMember>(c => c.Equals(channelMember))))
                .Returns(channelMemberResponse)
                .Verifiable();

                channelMemberResponses.Add(channelMemberResponse);
            }

            // Act
            var act = await _channelMemberService.GetChannelMembersAsync(channelId);;

            // Assert
            act.Should().BeEquivalentTo(channelMemberResponses);
        }