Example #1
0
        public void OrganizationDomainMapper_Dto_ReturnsDomain(OrganizationDto organizationDto)
        {
            //Arrange
            IMapper <OrganizationDto, Organization> mapper = new OrganizationDomainMapper();

            //Act
            var org = mapper.Map(organizationDto).ToOutFormat();

            //Actual
            //   --- OrganizationId
            org.Id.Id.Should().Be(organizationDto.Id);

            //   --- OrganizationName
            org.Name.Name.Should().Be(organizationDto.Name);

            //   --- Address
            org.Address.Street.Should().Be(organizationDto.Street);
            org.Address.StreetExtended.Should().Be(organizationDto.StreetExtended);
            org.Address.PostalCode.Should().Be(organizationDto.PostalCode);
            org.Address.City.Should().Be(organizationDto.City);
            org.Address.Country.Should().Be(organizationDto.Country);

            //   --- VatNumber
            org.VatNumber.VatNumberString.Should().Be(organizationDto.VatNumber);

            //   --- Website
            org.Website.Should().Be(organizationDto.Website);


            //   --- Meta
            org.ChangeDate.Should().Be(organizationDto.ChangeDate);
            org.ChangedBy.Should().Be(organizationDto.ChangedBy);
        }
        public void OrganizationDomainMapper_EntityWithoutMembers_ReturnsDomain(OrganizationEntity organizationEntity, OrganizationMember orgMember)
        {
            //Arrange
            var memberMapper = new Mock <IMapper <OrganizationMemberEntity, OrganizationMember> >();

            memberMapper.Setup(x => x.Map(It.IsAny <OrganizationMemberEntity>())).Returns(memberMapper.Object);
            memberMapper.Setup(x => x.ToOutFormat()).Returns(orgMember);

            var sut = new OrganizationDomainMapper(memberMapper.Object);

            //Act
            var actual = sut.Map(organizationEntity).ToOutFormat();

            //Assert
            actual.Members.Should().HaveCount(0);

            memberMapper.Verify(x => x.Map(It.IsAny <OrganizationMemberEntity>()), Times.Never);
        }
        public void OrganizationDomainMapper_Entity_ReturnsDomain(OrganizationEntity organizationEntity, OrganizationMember orgMember)
        {
            //Arrange
            var memberMapper = new Mock <IMapper <OrganizationMemberEntity, OrganizationMember> >();

            memberMapper.Setup(x => x.Map(It.IsAny <OrganizationMemberEntity>())).Returns(memberMapper.Object);
            memberMapper.Setup(x => x.ToOutFormat()).Returns(orgMember);

            var sut = new OrganizationDomainMapper(memberMapper.Object);

            //Act
            var actual = sut.Map(organizationEntity).ToOutFormat();

            //Assert
            actual.Id.Should().BeEquivalentTo(organizationEntity, options => options.ExcludingMissingMembers());
            actual.Name.Should().BeEquivalentTo(organizationEntity, options => options.ExcludingMissingMembers());
            actual.Address.Should().BeEquivalentTo(organizationEntity, options => options.ExcludingMissingMembers());
            actual.VatNumber.Should().BeEquivalentTo(organizationEntity, options => options.ExcludingMissingMembers());
            actual.Website.Should().Be(organizationEntity.Website);
            actual.ChangeDate.Should().Be(organizationEntity.ChangeDate);
            actual.ChangedBy.Should().Be(organizationEntity.ChangedBy);
        }