public static CustomerTestBuilder ACustomer()
 {
     return(new CustomerTestBuilder(Customer.CustomerBuilder.Customer()
                                    .WithFirstname("Tom")
                                    .WithLastname("Thompson")
                                    .WithAddress(AddressTestBuilder.AnAddress().Build())
                                    .WithEmail(EmailTestBuilder.AnEmail().Build())
                                    .WithPhoneNumber(PhoneNumberTestBuilder.APhoneNumber().Build())
                                    ));
 }
예제 #2
0
        public void ToDto()
        {
            Guid   customerId = Guid.NewGuid();
            string firstname  = "Koen";
            string lastname   = "Kasteels";

            Address     address     = AddressTestBuilder.AnAddress().Build();
            Email       email       = EmailTestBuilder.AnEmail().Build();
            PhoneNumber phoneNumber = PhoneNumberTestBuilder.APhoneNumber().Build();

            Customer customer = Customer.CustomerBuilder.Customer()
                                .WithId(customerId)
                                .WithFirstname(firstname)
                                .WithLastname(lastname)
                                .WithAddress(address)
                                .WithEmail(email)
                                .WithPhoneNumber(phoneNumber)
                                .Build();

            // when
            CustomerDto customerDto = _customerMapper.ToDto(customer);

            // then
            Assert.Equal(customerId.ToString("N"), customerDto.Id);
            Assert.Equal(firstname, customerDto.FirstName);
            Assert.Equal(lastname, customerDto.LastName);

            Assert.Equal("Jantjesstraat", customerDto.Address.StreetName);
            Assert.Equal("16A", customerDto.Address.HouseNumber);
            Assert.Equal("3000", customerDto.Address.PostalCode);
            Assert.Equal("Belgium", customerDto.Address.Country);

            Assert.Equal("niels", customerDto.Email.LocalPart);
            Assert.Equal("mymail.be", customerDto.Email.Domain);
            Assert.Equal("*****@*****.**", customerDto.Email.Complete);

            Assert.Equal("484554433", customerDto.PhoneNumber.Number);
            Assert.Equal("+32", customerDto.PhoneNumber.CountryCallingCode);
        }