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); } }
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})."); }
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); }
/// <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 }
private void OnProductAdded(object sender, ProductEventArgs e) { ProductViewModel viewModel = new ProductViewModel(e.Product, repositorys); // delegate this.PropertyChanged += this.OnProductViewModelPropertyChanged; this.AllProducts.Add(viewModel); }
private void OnProductRemoved(object sender, ProductEventArgs e) { ProductViewModel viewModel = this.GetOnlySelectedViewModel(); if (viewModel != null) { if (viewModel.Product == e.Product) { this.AllProducts.Remove(viewModel); } } }
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 { } }
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); } } }
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); }
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); }
private void ProductView_AddedProductEvent(object sender, ProductEventArgs e) { Product = e.Product; writer.AddProduct(Product); }
private void ShopView_RemoveProductEvent(object sender, ProductEventArgs e) { writer.RemoveProduct(e.Product); shopView.RemoveProduct(e.Product); }
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); }