示例#1
0
        private void WaitForUserAction()
        {
            Console.WriteLine(string.Empty);
            Console.WriteLine("To order product type 'o' and product index (ex. o2)");
            Console.WriteLine("To view product details type 'd' and product index (ex. d2)");
            Console.WriteLine("To exit type 0");
            string userInput = Console.ReadLine();

            int  productIndex;
            bool correctIndex = int.TryParse(userInput.Substring(1, userInput.Length - 1), out productIndex);

            if (correctIndex && productIndex < this.products.Length)
            {
                ProductEventArgs args = new ProductEventArgs {
                    Product = this.products[productIndex]
                };

                if (userInput.StartsWith("o"))
                {
                    OrderRequested(null, args);
                }
                else if (userInput.StartsWith("d"))
                {
                    DetailsRequested(null, args);
                }
            }
            else if (userInput == "0")
            {
                ExitRequested(null, EventArgs.Empty);

                return;
            }

            WaitForUserAction();
        }
 /// <summary>
 /// Raise product updated event
 /// </summary>
 /// <param name="source">Source</param>
 /// <param name="e">Arguments</param>
 public virtual void OnProductUpdated(object source, ProductEventArgs e)
 {
     if (this.ProductUpdated != null)
     {
         this.ProductUpdated(source, e);
     }
 }
示例#3
0
        public void Adding_A_Valid_Product_Fire_Event()
        {
            // Setup our product so that it always returns true on a IsValid verification
            Mock <IProduct> product = new Mock <IProduct>();

            product.Setup(currentProduct => currentProduct.IsValid).Returns(true);

            // setup an event argument for our event
            ProductEventArgs productEventArgs = new ProductEventArgs(product.Object);

            // setup a mocked shopping cart to create our mocked event handler and a true shopping cart to test
            Mock <ShoppingCart> mockedShoppingCart = new Mock <ShoppingCart>();

            //creating the event a mocked event
            // Raising an event on the mock mock.Raise(m => m.FooEvent += null, new FooEventArgs(fooValue));
            // Causing an event to raise automatically when Submit is invoked mock.Setup(foo => foo.Submit()).Raises(f => f.Sent += null, EventArgs.Empty);
            //DEPRICATED MockedEvent<ProductEventArgs> mockedEvent = mockedShoppingCart.CreateEventHandler<ProductEventArgs>();
            //mockedShoppingCart.Object.ProductAdded += mockedEvent;
            mockedShoppingCart.Setup(shopping => shopping.Add(product.Object))
            .Raises(f => f.ProductAdded += null, new ProductEventArgs(product.Object))
            .Verifiable();

            //making the test
            IShoppingCart myShoppingCart = mockedShoppingCart.Object;

            myShoppingCart.Add(product.Object);

            mockedShoppingCart.Verify();
        }
        public static void OnProductUpdated(Product product, ProductEventArgs e)
        {
            // Alert When Product Comes Back in Stock
            //var recipients = new CustomerSmsAlertService().GetRecipients(product.ProductID);

            Console.WriteLine($"[SMS Alert] '{product.ProductName}' is back in stock ({e.ModifiedAt}).");
        }
示例#5
0
        private void OnProductAdded(object sender, ProductEventArgs e)
        {
            ProductViewModel vm = new ProductViewModel(e.Product, this.repository);

            vm.PropertyChanged += this.OnProductViewModelPropertyChanged;

            this.AllProducts.Add(vm);
        }
        /// <summary>
        /// What happens when adding a product.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event argument.</param>
        private void OnProductAdded(object sender, ProductEventArgs e)
        {
            ProductViewModel viewModel = new ProductViewModel(e.Product, this.repo);

            viewModel.PropertyChanged += this.OnProductViewModelPropertyChanged;

            this.AllProducts.Add(viewModel);
        }
示例#7
0
        /// <summary>
        /// termék megváltozásának eseménykezelése.
        /// </summary>
        private void Model_ProductChanged(object sender, ProductEventArgs e)
        {
            Int32 index = Products.IndexOf(Products.FirstOrDefault(product => product.ModellNumber == e.PorductModellNumber));

            Products.RemoveAt(index); // módosítjuk a kollekciót
            Products.Insert(index, _model.Products[index]);

            SelectedProduct = Products[index]; // és az aktuális terméket
        }
示例#8
0
        private void OnProductAdded(object sender, ProductEventArgs e)
        {
            ProductViewModel viewModel = new ProductViewModel(e.Product, repositorys);

            // delegate
            this.PropertyChanged += this.OnProductViewModelPropertyChanged;


            this.AllProducts.Add(viewModel);
        }
示例#9
0
        private void OnProductRemoved(object sender, ProductEventArgs e)
        {
            ProductViewModel viewModel = this.GetOnlySelectedViewModel();

            if (viewModel != null)
            {
                if (viewModel.Product == e.Product)
                {
                    this.AllProducts.Remove(viewModel);
                }
            }
        }
示例#10
0
        private async void OnProductInfoUpdatedHandler(object sender, ProductEventArgs e)
        {
            double percents = (e.ProductProcessed + _dbGoodProductsCountOfChapter) /
                              ((e.AllProductsCount + _dbGoodProductsCountOfChapter) / 100.0);

            ProductProcessingStatus = $"Обработка раздела: {percents: 0.00} %";
            var products = e.Products.Where(p => Filters.IsGoodProduct(p, FiltersManagerVM.FiltersVM.Model)).ToList();

            try
            {
                await AddToResultsAsync(products).ConfigureAwait(false);
            }
            catch
            {
            }
        }
示例#11
0
 private void OnAddProduct()
 {
     if (this.eventAddProduct != null)
     {
         bool isAllRight = true;
         JudgeTextBox(ref isAllRight);
         if (isAllRight == true)
         {
             ProductEventArgs productArgs = new ProductEventArgs();
             productArgs.ProductCode = this.tb_ProductCode.Text.Trim();
             productArgs.ProductName = this.tb_ProductName.Text.Trim();
             productArgs.ProductUnit = this.tb_ProductUnit.Text.Trim();
             productArgs.FullNum     = int.Parse(this.tb_FullNum.Text.Trim());
             this.eventAddProduct.Invoke(this, productArgs);
         }
     }
 }
示例#12
0
        public void Adding_A_Valid_Product_Fire_Event1()
        {
            // Setup our product so that it always returns true on a IsValid verification
            Mock <IProduct> product = new Mock <IProduct>();

            product.Setup(currentProduct => currentProduct.IsValid).Returns(true);

            // setup an event argument for our event
            ProductEventArgs productEventArgs = new ProductEventArgs(product.Object);

            // creating our objects and events
            ShoppingCart myShoppingCart = new ShoppingCart();
            bool         isCalled       = false;

            myShoppingCart.ProductAdded += (sender, e) => isCalled = true;

            // Testing the Add method if it fire the event
            myShoppingCart.Add(product.Object);

            // make sure the event was called
            Assert.Equal(isCalled, true);
        }
示例#13
0
        private void OnProductSelected(object sender, ProductEventArgs e)
        {
            ProductItem productItem = (ProductItem)sender;

            ProductDetailsPanel.Open(productItem);
        }
        public void productsAdded(object sender, ProductEventArgs args)
        {
            int index = this.productFacade.getIndex((Product)sender);

            this.communicationFacade.enableButton(index);
        }
示例#15
0
 private void ProductView_AddedProductEvent(object sender, ProductEventArgs e)
 {
     Product = e.Product;
     writer.AddProduct(Product);
 }
示例#16
0
 private void ShopView_RemoveProductEvent(object sender, ProductEventArgs e)
 {
     writer.RemoveProduct(e.Product);
     shopView.RemoveProduct(e.Product);
 }
示例#17
0
 private void OnProductUpdating(ProductEventArgs e)
 {
     if ((this.ProductUpdating != null))
     {
         this.ProductUpdating(this, e);
     }
 }
 //===Products have been added, example event to communicate with listeners
 public void notifyProductsAdded(object sender, ProductEventArgs args)
 {
     this.productsAddedEvent(sender, args);
 }