Example #1
0
        public void Should_map_MemberDtos_to_MemberEntities()
        {
            var memberAtCommunity3 = _fixture.Build <MemberDto>()
                                     .With(x => x.CommunityId, 3)
                                     .Create();
            var memberAtCommunity2 = _fixture.Build <MemberDto>()
                                     .With(x => x.Id, memberAtCommunity3.Id)
                                     .With(x => x.CommunityId, 2)
                                     .With(x => x.Email, memberAtCommunity3.Email)
                                     .With(x => x.FirstName, memberAtCommunity3.FirstName)
                                     .With(x => x.LastName, memberAtCommunity3.LastName)
                                     .With(x => x.Role, memberAtCommunity3.Role)
                                     .Create();

            var members = new List <MemberDto> {
                memberAtCommunity3, memberAtCommunity2
            };
            var result = _memberDao.ConvertDtos(members).Result;

            result.Count().Should().Be(1);
            result.First().Email.Should().Be(memberAtCommunity3.Email);
            result.First().FirstName.Should().Be(memberAtCommunity3.FirstName);
            result.First().LastName.Should().Be(memberAtCommunity3.LastName);
            result.First().Role.Should().Be((CommunityRole)memberAtCommunity3.Role);
            result.First().Id.Should().Be(memberAtCommunity3.Id);
            result.First().Communities.Should().Contain(c => c.Id == memberAtCommunity3.CommunityId);
            result.First().Communities.Should().Contain(c => c.Id == memberAtCommunity2.CommunityId);
        }