public void Then_an_InvalidDeliveryAddressException_will_be_thrown()
        {
            var address = new Address("My Street", string.Empty, "My City", "My State", "My Country", "My Zip");

            var deliveryAddress = new DeliveryAddress("My Address", null, address);

            Assert.Fail();
        }
        public void Then_an_InvalidDeliveryAddressException_should_be_thrown()
        {
            var customer = new Customer("jhkjhkjhkj",
                                      new EmailAddress("*****@*****.**"),
                                      new Name("Scott", "Millett"));

            var invalidDeliveryAddress = new DeliveryAddress("My Work Address", customer, null);

            Assert.Fail();
        }
        public void SetUp()
        {
            var address = new Address("My Street", string.Empty, "My City", "My State", "My Country", "My Zip");

            var customer = new Customer("jhkjhkjhkj", 
                                        new EmailAddress("*****@*****.**"),
                                        new Name("Scott", "Millett"));

            sut = new DeliveryAddress("My Delivery Address", customer, address);

            When();
        }
Beispiel #4
0
        private void ThrowExceptionIfAddressIsInvalid(DeliveryAddress deliveryAddress)
        {
            if (deliveryAddress.GetBrokenRules().Count() > 0)
            {
                StringBuilder deliveryAddressIssues = new StringBuilder();
                deliveryAddressIssues.AppendLine("There were some issues with the address you are adding.");

                foreach (BusinessRule rule in deliveryAddress.GetBrokenRules())
                {
                    deliveryAddressIssues.AppendLine(rule.Rule);
                }

                throw new InvalidAddressException(deliveryAddressIssues.ToString());
            }
        }
        public DeliveryAddressAddResponse AddDeliveryAddress(DeliveryAddressAddRequest request)
        {
            DeliveryAddressAddResponse response = new DeliveryAddressAddResponse();
            Customer customer = _customerRepository.FindBy(request.CustomerIdentityToken);
            DeliveryAddress deliveryAddress = new DeliveryAddress();

            deliveryAddress.Customer = customer;
            UpdateDeliveryAddressFrom(request.Address, deliveryAddress);

            customer.AddAddress(deliveryAddress);

            _customerRepository.Save(customer);
            _uow.Commit();

            response.DeliveryAddress = deliveryAddress.ConvertToDeliveryAddressView();

            return response;
        }
 private void UpdateDeliveryAddressFrom(DeliveryAddressView deliveryAddressSource, DeliveryAddress deliveryAddressToUpdate)
 {
     deliveryAddressToUpdate.Name = deliveryAddressSource.Name;
     deliveryAddressToUpdate.AddressLine1 = deliveryAddressSource.AddressLine1;
     deliveryAddressToUpdate.AddressLine2 = deliveryAddressSource.AddressLine2;
     deliveryAddressToUpdate.City = deliveryAddressSource.City;
     deliveryAddressToUpdate.State = deliveryAddressSource.State;
     deliveryAddressToUpdate.Country = deliveryAddressSource.Country;
     deliveryAddressToUpdate.ZipCode = deliveryAddressSource.ZipCode;
 }
        public void AddAddress(DeliveryAddress deliveryAddress)
        {
            ThrowExceptionIfAddressIsInvalid(deliveryAddress);

            _deliveryAddressBook.Add(deliveryAddress);
        }
 public void Then_an_InvalidDeliveryAddressException_should_be_thrown()
 {
     var invalidDeliveryAddress = new DeliveryAddress(string.Empty, _customer, _address);
 }