Beispiel #1
0
 public TradeItem(IProductItem productItem, int purchaseQuantity, decimal totalPrice)
     : this()
 {
     //Todo
     this.PurchaseQuantity = purchaseQuantity;
     this.TotalPrice       = totalPrice;
 }
Beispiel #2
0
        public TradeItem(IProductItem productItem, int purchaseQuantity, decimal totalPrice)
            : this()
        {
            //Todo
            this.PurchaseQuantity = purchaseQuantity;
            this.TotalPrice = totalPrice;

        }
        public void AddProductItem(IProductItem productItem)
        {
            if (_productItems.Keys.Contains(productItem.Name))
            {
                _productItems[productItem.Name].Add(productItem);
                return;
            }

            _productItems.Add(productItem.Name, new AddableProductItem(productItem));
        }
Beispiel #4
0
        public Product(ProductItemCollection productItems, OptionCollection options)
        {
            Mandate.ParameterNotNull(productItems, "productItems");
            Mandate.ParameterNotNull(options, "options");
            Mandate.ParameterCondition(GetSingleItem() != null, "productItems must contain a template item");

            _productItems = productItems;
            _options = options;
            _singleItem = GetSingleItem();
        }
Beispiel #5
0
        public Product(ProductItemCollection productItems, OptionCollection options)
        {
            Mandate.ParameterNotNull(productItems, "productItems");
            Mandate.ParameterNotNull(options, "options");
            Mandate.ParameterCondition(GetSingleItem() != null, "productItems must contain a template item");

            _productItems = productItems;
            _options      = options;
            _singleItem   = GetSingleItem();
        }
        public void GivenNoObject_WhenCreatingProductItemWithParticularQuantity_ThenReturnsQuantityAsExpected()
        {
            // Arrange
            const uint expectedQuantity = 10;

            //  Act
            IProductItem productItem = CreateProductItem(injectedQuantity: expectedQuantity);

            // Assert
            Assert.That(productItem.Quantity, Is.EqualTo(expectedQuantity));
        }
        public void GivenNoObject_WhenCreatingProductItemWithProductOfParticularUnitPrice_ThenReturnsUnitPriceAsExpected()
        {
            // Arrange
            const double expectedUnitPrice = 39.99;

            //  Act
            IProductItem productItem = CreateProductItem(injectedProductUnitPrice: expectedUnitPrice);

            // Assert
            Assert.That(productItem.UnitPrice, Is.EqualTo(expectedUnitPrice));
        }
        public void GivenNoObject_WhenCreatingProductItemWithProductOfParticularName_ThenReturnsNameAsExpected()
        {
            // Arrange
            const string expectedName = "Expected Product Name";

            //  Act
            IProductItem productItem = CreateProductItem(injectedProductName: expectedName);

            // Assert
            Assert.That(productItem.Name, Is.EqualTo(expectedName));
        }
        public void GivenProductItem_WhenGetPrice_ThenReturnsQuantityTimesUnitPrice()
        {
            // Arrange
            const uint   expectedProductUnitPrice = 70;
            const uint   expectedQuantity         = 10;
            IProductItem productItem = CreateProductItem(injectedProductUnitPrice: expectedProductUnitPrice, injectedQuantity: expectedQuantity);

            //  Act
            var productItemPrice = productItem.Price;

            // Assert
            Assert.That(productItemPrice, Is.EqualTo(expectedQuantity * expectedProductUnitPrice));
        }
Beispiel #10
0
        public void Add(IProductItem productItemToAdd)
        {
            if (productItemToAdd == null)
            {
                throw new ArgumentNullException($"{nameof(productItemToAdd)} cannot be null");
            }

            if (productItemToAdd.Name != Name)
            {
                throw new ArgumentException($"Only product items with same product name can be added." +
                                            $"Product name for product item asked to add is - {productItemToAdd.Name}");
            }

            _productItem = new ProductItem(new Product(Name, UnitPrice), Quantity + productItemToAdd.Quantity);
        }
        // TODO : This is super rough.  Needs testing
        public static IProductItem GetForAttributes(this IProduct product, int[] attributeIds)
        {
            var match = attributeIds.ToList().OrderBy(x => x);

            IProductItem pi = null;

            foreach (var item in product.ProductItems.Where(x => x.SingleItem == false))
            {
                var atts = (item.Attributes.Select(x => x.Id)).OrderBy(x => x);
                if (atts != match)
                {
                    continue;
                }
                pi = item;
                break;
            }

            return(pi);
        }
 private ListViewItem GetListViewItem(IProductItem _selectedItem, double quantity)
 {
     ListViewItem orderRow = new ListViewItem(_selectedItem.NickName);
     orderRow.SubItems.Add(_selectedItem.Price.ToString("C2"));
     orderRow.SubItems.Add(quantity.ToString());
     double subtotal = _selectedItem.Price * quantity;
     orderRow.SubItems.Add(subtotal.ToString("C2"));
     return orderRow;
 }
Beispiel #13
0
 public AddableProductItem(IProductItem productItem)
 {
     _productItem = productItem;
 }
 public ProductGridPage(IWebDriver driver, IProductItem productItem) : base(driver)
 {
     _driver      = driver;
     _productItem = productItem;
 }
 private void InitializeFlowPanel(FlowLayoutPanel panel, IEnumerable<IProductItem> items)
 {
     foreach (IProductItem item in items)
     {
         Button button = new Button();
         button.Text = item.NickName;
         button.BackgroundImage = item.Image;
         button.FlatStyle = FlatStyle.Flat;
         button.ImageAlign = ContentAlignment.MiddleCenter;
         button.TextAlign = ContentAlignment.MiddleCenter;
         button.BackgroundImageLayout = ImageLayout.Stretch;
         button.Width = button.Height = 120;
         button.Click += new EventHandler((object e, EventArgs e1) =>
                                             {
                                                 _selectedItem = item;
                                                 SelectedItemButton = button;
                                             });
         panel.Controls.Add(button);
         panel.AutoScroll = true;
     }
 }
        private IProductOrderInfo GetProductOrder(DateTime date, ICompanyInfo company, IProductItem item, double quantity)
        {
            SharedUtility.ThrowIfNull(date, "date");
            SharedUtility.ThrowIfNull(company, "company");
            SharedUtility.ThrowIfNull(item, "item");

            ProductOrderInfo order = new ProductOrderInfo();
            order.OrderDate = date;
            order.ProductItem = item;
            order.Quantity = quantity;
            order.Company = company;
            return order;
        }
 public void AddProductItem(IProductItem productItem)
 {
     _productItems.Add(productItem);
 }
Beispiel #18
0
        public ProductAndTaxesAndFinalPrice GetProductWithTaxes(IProductItem productItem, List<ITax> Taxes)
        {
            /// TODO: Redesign so that tax types are added to the product.
            /// TODO: Kill the interfaces by morphing most of them into abstract base classes and restore encapsulation.

            return this; // Returns the instance of itself because the class is a bit of a egomaniac.
        }