Ejemplo n.º 1
0
        //[InlineData(new MockOrderItem[] { new MockOrderItem(), new MockOrderItem})]
        public void ItemsShouldContainOnlyAddedItems()
        {
            var order = new Order();
            var items = new IOrderItems[]
            {
                new MocKOrderItem()
                {
                    Price = 3
                },
                new MocKOrderItem()
                {
                    Price = 4
                },
                new MocKOrderItem()
                {
                    Price = 7
                },
            };

            foreach (var item in items)
            {
                order.Add(item);
            }
            Assert.Equal(items.Length, order.Items.Count());
            foreach (var item in items)
            {
                Assert.Contains(item, order.Items);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// removes an item from the list
        /// </summary>
        /// <param name="item">selected item</param>
        public void Remove(IOrderItems item)
        {
            if (item is INotifyPropertyChanged notifier)
            {
                notifier.PropertyChanged -= OnItemPropertyChanged;
            }

            items.Remove(item);
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Items"));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Subtotal"));
        }
        /// <summary>
        /// this helper method add the item to the list and swaps the screen
        /// </summary>
        /// <param name="item">item user clicked to be added</param>
        /// <param name="screen">sreen to be swapped</param>
        void AddItemAndOpenCustomizationScreen(IOrderItems item, FrameworkElement screen)
        {
            var order = DataContext as Order;

            if (order == null)
            {
                throw new Exception("Data Context expected to be order instance");
            }
            if (screen != null)
            {
                var orderControl = this.FindAncestor <OrderControl>();
                if (orderControl == null)
                {
                    throw new Exception("An ancestor of ordercontrol expected");
                }

                screen.DataContext = item;
                orderControl.SwapScreen(screen);
            }
            order.Add(item);
        }
Ejemplo n.º 4
0
 internal IOrderItems LoadOrderItems()
 {
     OrderItems = new OrderItems(Id);
 }