public OrderCreationUseCaseTest()
        {
            var food = new Category {
                Name          = "food",
                TaxPercentage = 10m
            };

            _productCatalog = new InMemoryProductCatalog(new List <Product>
            {
                new Product
                {
                    Name     = "salad",
                    Price    = 3.56m,
                    Category = food
                },
                new Product
                {
                    Name     = "tomato",
                    Price    = 4.65m,
                    Category = food
                }
            });

            _orderRepository = new TestOrderRepository();

            _useCase = new OrderCreationUseCase(_orderRepository, _productCatalog);
        }
 public CashRegisterProcessor(
     IProductCatalog productCatalog,
     ICashRegisterRenderer cashRegisterRenderer)
 {
     _productCatalog       = productCatalog;
     _cashRegisterRenderer = cashRegisterRenderer;
 }
        Product[] GetProductDetails(IProductCatalog client, IEnumerable<string> productIds)
        {
            if (productIds == null)
                throw new ArgumentNullException("productIds");

            if (!productIds.Any())
                return new Product[] { };

            var products = productIds
                .Chunk(10)
                .SelectMany
                (
                    chunk =>
                    {
                        var query = new ProductQuery
                        {
                            Page        = 1,
                            PageSize    = int.MaxValue,
                            SearchTerms = string.Join(" ", chunk.ToArray()),
                            SearchField = ProductQuery.SearchFields.ProductId
                        };

                        return client.Search(query).Products;
                    }
                )
                .ToArray();

            return products;
        }
Ejemplo n.º 4
0
        public void MultipleProducts_Mocks()
        {
            // Arrange
            var cart = A.Fake <ICart>();

            A.CallTo(() => cart.Products).Returns(new [] {
                new ProductToPurchase {
                    ProductId = 1, Quantity = 1
                },
                new ProductToPurchase {
                    ProductId = 42, Quantity = 7
                },
            });

            IProductCatalog mockProductCatalog = A.Fake <IProductCatalog>();

            A.CallTo(() => mockProductCatalog.LookupPrice(1)).Returns(1m);
            A.CallTo(() => mockProductCatalog.LookupPrice(42)).Returns(1.5m);

            ITaxCalculator mockTaxCalculator = A.Fake <ITaxCalculator>();

            A.CallTo(() => mockTaxCalculator.CalculateTaxes(11.5m)).Returns(1.15m);

            // Act
            var            calculator = new PricingCalculator(mockProductCatalog, mockTaxCalculator);
            PricingSummary price      = calculator.PriceCart(cart);

            // Assert
            Assert.That(price.ProductPrices.Count, Is.EqualTo(2));
            Assert.That(price.SubTotal, Is.EqualTo(11.5m));
            Assert.That(price.Taxes, Is.EqualTo(1.15m));
            Assert.That(price.Total, Is.EqualTo(12.65m));
        }
 public OrderCreationUseCase(
     IOrderRepository orderRepository,
     IProductCatalog productCatalog)
 {
     _orderRepository = orderRepository;
     _productCatalog  = productCatalog;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="catalogus">The product catalogus to supply the products and
 /// search of products</param>
 public Till(IProductCatalog catalogus, ICashRegister cashRegister)
 {
     if (catalogus == null || cashRegister == null)
     {
         throw new ArgumentNullException("The catalog or register does not exist");
     }
     this.Catalog  = catalogus;
     this.Register = cashRegister;
 }
Ejemplo n.º 7
0
 public OrderRepository(PaymentHandler paymentHandler,
                        IProductCatalog productCatalog,
                        IPaymentService paymentService)
 {
     orders = new Order[] {};
     this.paymentHandler = paymentHandler;
     this.productCatalog = productCatalog;
     this.paymentService = paymentService;
 }
Ejemplo n.º 8
0
 public PaymentHandler(Func <IPackingSlipBuilder> _packingSlipBuilder,
                       IProductCatalog productCatalog,
                       IMembershipService membershipService,
                       ICommisionService commisionService)
 {
     packingSlipBuilder     = _packingSlipBuilder;
     this.productCatalog    = productCatalog;
     this.membershipService = membershipService;
     this.commisionService  = commisionService;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="catalogus">The product catalogus to supply the products and search of products</param>
        public Till(IProductCatalog catalogus)
        {
            if (catalogus == null)
            {
                throw new ObjectIsNullException("The catalog does not exist");
            }
            this.List = catalogus;

            // throw new NotImplementedException();
        }
 public ProductValidatorManager(IProductCatalog productCatalog)
 {
     this.productCatalog = productCatalog;
     validatorMap        = new Dictionary <Type, IProductValidator>
     {
         { typeof(Product), new ProductValidator() },
         { typeof(Book), new BookValidator(productCatalog) },
         { typeof(Toy), new ToyValidator(productCatalog) },
         { typeof(Appliances), new AppliancesValidator(productCatalog) }
     };
 }
Ejemplo n.º 11
0
 public OrderCreationUseCaseTest()
 {
     orderRepository  = new TestOrderRepository();
     food             = new Category("Food", 10m);
     productCatalogue = new InMemoryProductCatalog(
         new List <Product>()
     {
         new Product("salad", food, 3.56m),
         new Product("tomato", food, 4.65m)
     });
     useCase = new OrderCreationUseCase(orderRepository, productCatalogue);
 }
 public void SetUp()
 {
     orderRepository = new TestOrderRepository();
     food            = new Category {
         Name = "Food", TaxPercentage = new decimal(10)
     };
     productCatalogue = new InMemoryProductCatalog(
         new List <Product> {
         new Product {
             Category = food, Name = "salad", Price = new decimal(3.56)
         }, new Product {
             Category = food, Name = "tomato", Price = new decimal(4.65)
         }
     });
     useCase = new OrderCreationUseCase(orderRepository, productCatalogue);
 }
        public ListCommand(IProductCatalog productCatalog, string[] args)
        {
            productTypeDoesntExist = resourceManager.GetString("LIST_PRODUCTTYPEDOESNTEXIST");
            usage = resourceManager.GetString("LIST_USAGE");
            this.productCatalog = productCatalog;
            var buffer = new StringBuilder(64);

            buffer.Append(productTypeDoesntExist);
            var names = productCatalog.GetTypeNames();

            foreach (var name in names)
            {
                buffer.Append("-");
                buffer.Append(name);
                buffer.Append(Environment.NewLine);
            }

            productTypeDoesntExist = buffer.ToString();
        }
        public CreateCommand(IProductCatalog productCatalog, string[] args)
        {
            productTypeDoesntExist = resourceManager.GetString("CREATE_PRODUCTTYPEDOESNTEXIST");
            this.args           = args;
            this.productCatalog = productCatalog;
            validator           = productCatalog.GetValidator();
            var buffer = new StringBuilder(64);

            buffer.Append(productTypeDoesntExist);
            var names = productCatalog.GetTypeNames();

            foreach (var name in names)
            {
                buffer.Append("-");
                buffer.Append(name);
                buffer.Append(Environment.NewLine);
            }

            productTypeDoesntExist = buffer.ToString();
        }
Ejemplo n.º 15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="productCatalog"></param>
 public ScannerSessionController(IProductCatalog productCatalog)
 {
     _productCatalog = productCatalog;
 }
Ejemplo n.º 16
0
 public StoreController(IProductCatalog productCatalog, IShoppingCartLocator shoppingCartLocator)
 {
     _productCatalog      = productCatalog;
     _shoppingCartLocator = shoppingCartLocator;
 }
Ejemplo n.º 17
0
 public ProductsController(IProductCatalog catalog)
 {
     _catalog = catalog;
 }
Ejemplo n.º 18
0
 public GetItemCommand(IProductCatalog productCatalog, string[] args)
 {
     usage = resourceManager.GetString("GETITEM_USAGE");
     this.productCatalog = productCatalog;
     this.args           = args;
 }
Ejemplo n.º 19
0
 public ProductController(IProductCatalog repo)
 {
     repository = repo;
 }
Ejemplo n.º 20
0
 public OrderCreation(IOrderRepository orderRepository, IProductCatalog productCatalog)
 {
     _productCatalog  = productCatalog;
     _orderRepository = orderRepository;
 }
Ejemplo n.º 21
0
 public StoreController(IProductCatalog productCatalog, IShoppingCartLocator shoppingCartLocator)
 {
     _productCatalog = productCatalog;
     _shoppingCartLocator = shoppingCartLocator;
 }
Ejemplo n.º 22
0
 public PromotionEngine(IProductCatalog productCatalog, IPromotionsCatalog promotionsCatalog)
 {
     ProductCatalog    = (ProductCatalog)productCatalog;
     PromotionsCatalog = (PromotionsCatalog)promotionsCatalog;
 }
Ejemplo n.º 23
0
 public PricingCalculator(IProductCatalog catalogService, ITaxCalculator pricingService)
 {
     this.catalog       = catalogService;
     this.taxCalculator = pricingService;
 }
Ejemplo n.º 24
0
 public ProductsController(IProductCatalog catalog, IShoppingCart cart)
 {
     _catalog = catalog;
     _cart    = cart;
 }
Ejemplo n.º 25
0
 public ProcessOrder(IProductCatalog catalog)
 {
     _catalog = catalog;
 }
 public Dispatcher()
 {
     productCatalog = new ProductCatalog("product_data");
     help           = resourceManager.GetString("HELP");
 }
Ejemplo n.º 27
0
 public void Setup()
 {
     productTestCatalog = new ProductCatalog("testDataCatalog");
     productTestCatalog.ClearListCatalog();
 }
 public ProductsController(IProductCatalog catalog)
 {
     this.catalog = catalog;
 }
 public AddCountCommand(IProductCatalog productCatalog, string[] args)
 {
     usage = resourceManager.GetString("ADDCOUNT_USAGE");
     this.productCatalog = productCatalog;
     this.args           = args;
 }
Ejemplo n.º 30
0
 private CartController(IProductCatalog productCatalog)
 {
     this.productCatalog = productCatalog;
 }
 public ShoppingCartImpl(IProductCatalog catalog)
 {
     _catalog = catalog;
 }
Ejemplo n.º 32
0
 public BookValidator(IProductCatalog productCatalog)
 {
     this.productCatalog = productCatalog;
 }
 public SubstractCountCommand(IProductCatalog productCatalog, string[] args)
 {
     usage = resourceManager.GetString("SUBSTRACTCOUNT_USAGE");
     this.productCatalog = productCatalog;
     this.args           = args;
 }