protected override void PersistenceContext()
 {
     _product = new ProductBuilder().Build();
     _customer = new CustomerBuilder()
         .WithProductInBasket(_product, 23)
         .Build();
     Save(_product, _customer);
 }
 protected override void PersistenceContext()
 {
     var customerOne = new CustomerBuilder().Build();
     _customerTwo = new CustomerBuilder().Build();
     _customerTwo.SetDeliveryAddress("delivery address");
     
     Save(customerOne, _customerTwo);
 }
예제 #3
0
 public Customer Build()
 {
     var customer = new Customer();
     foreach (var basketItem in _basketItems)
     {
         customer.AddProductToBasket(basketItem.Product, basketItem.Quantity);
     }
     customer.SetDeliveryAddress(_deliveryAddress);
     return customer;
 }
        public void Context()
        {
            const int customerId = 45;
            _customer = Mock<Customer>();
            var customerRepository = Stub<IRepository<Customer>>().Stubs(x => x.GetById(customerId)).Returns(_customer);
            var handler = new SetDeliveryAddressCommandHandler(customerRepository);

            handler.Execute(new SetDeliveryAddressCommand
                                {
                                    CustomerId = customerId,
                                    Address = DeliveryAddress,
                                });
        }
        public void Context()
        {
            const int customerId = 45;
            _customer = Mock<Customer>();
            var customerRepository = Stub<IRepository<Customer>>().Stubs(x => x.GetById(customerId)).Returns(_customer);
            const int productId = 23;
            _product = Stub<Product>();
            var productRepository = Stub<IRepository<Product>>().Stubs(x => x.GetById(productId)).Returns(_product);
            var handler = new UpdateProductQuantityInBasketCommandHandler(customerRepository, productRepository);

            handler.Execute(new UpdateProductQuantityInBasketCommand
                                {
                                    CustomerId = customerId,
                                    ProductId = productId,
                                    Quantity = NewQuantity
                                });
        }
        public void Context()
        {
            _customerRepository = Mock<IRepository<Customer>>();
            const int productId = 23;
            _product = Stub<Product>();
            var productRepository = Stub<IRepository<Product>>().Stubs(x => x.GetById(productId)).Returns(_product);
            _customer = Mock<Customer>().Stubs(x => x.Id).Returns(CustomerId);
            var customerFactory = Stub<ICustomerFactory>().Stubs(x => x.Create()).Returns(_customer);
            var handler = new AddProductToBasketCommandHandler(_customerRepository, productRepository, customerFactory);
            handler.CommandExecuted += (sender, args) => _customerIdRaisedByEvent = (int)args.Args; // todo: refactor CoreDdd to support generic event handling

            handler.Execute(new AddProductToBasketCommand
                                {
                                    CustomerId = default(int),
                                    ProductId = productId,
                                    Quantity = Quantity
                                });
        }
        protected override void PersistenceContext()
        {
            _productOne = new ProductBuilder()
                .WithName(ProductOneName)
                .WithPrice(ProductOnePrice)
                .Build();
            _productTwo = new ProductBuilder()
                .WithName(ProductTwoName)
                .WithPrice(ProductTwoPrice)
                .Build();
            _customer = new CustomerBuilder()
                .WithProductInBasket(_productOne, ProductOneQuantity)
                .WithProductInBasket(_productTwo, ProductTwoQuantity)
                .Build();
            var anotherCustomer = new CustomerBuilder()
                .WithProductInBasket(_productOne, ProductOneQuantity)
                .Build();

            Save(_productOne, _productTwo, _customer, anotherCustomer);
        }
예제 #8
0
 public OrderBuilder WithCustomer(Customer customer)
 {
     _customer = customer;
     return this;
 }
        public void Context()
        {
            var factory = new CustomerFactory();

            _customer = factory.Create();
        }
 protected override void PersistenceQuery()
 {
     _retrievedCustomer = Get<Customer>(_customer.Id);
 }