public void AddProduct_true() { _mock .Setup(e => e.GetAll()) .Returns(Getsome()); _mock .Setup(e => e.Delete(It.IsAny <Product>())); _mock .Setup(e => e.Add(It.IsAny <Product>())); _mock .Setup(e => e.Save()); var result = _productHandler.AddProduct(new Product() { Id = It.IsAny <int>(), ProductName = "hammer", Price = (decimal)3.99, StockLevel = 50, BarCode = It.IsAny <string>(), BrandId = It.IsAny <int>(), CategoriesId = It.IsAny <int>(), MinimumWholesaleOrder = It.IsAny <double>(), OrderLevel = It.IsAny <double>(), WholesalePrice = It.IsAny <double>() }); Assert.True(result); }
} //validacion private void Button_Click(object sender, RoutedEventArgs e) { if (verify) { productoHandler.ModifyProduct(producto, pos); MainWindow.myNavigationFrame.NavigationService.Navigate(new MainPage()); } else { String referencia = txt_Ref.Text; String tipo = txt_Tipo.Text; String marca = txt_Marca.Text; String precio = txt_Precio.Text; String stock = txt_Stock.Text; DateTime fechaAlta = (DateTime)txt_fechaAlta.SelectedDate; if (Validation()) { Producto producto = new Producto(referencia, tipo, marca, precio, stock, fechaAlta); productoHandler.AddProduct(producto); MainWindow.myNavigationFrame.NavigationService.Navigate(new MainPage()); } else { warning.Content = "ERROR, INTRODUCE LOS DATOS"; } } }
private void AddButton_OnClick(object sender, RoutedEventArgs e) { Item item; switch (_productType) { case ProductType.Alloywheel: item = new Alloywheel(Brand, Model, Stocks, UnitPrice, Dimension); break; case ProductType.Battery: item = new Battery(Brand, Model, Stocks, UnitPrice, Capacity, Voltage); break; case ProductType.Tyre: item = new Tyre(Brand, Model, Stocks, UnitPrice, Dimension, Country); break; default: throw new ArgumentOutOfRangeException(); } if (item.Validate()) { _productHandler.AddProduct(item); } else { MessageBox.Show("Some required information are missing. Please check again.", "Information", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } DialogResult = true; Close(); }
private void Button_Click(object sender, RoutedEventArgs e) { if (verify) { productoHandler.ModifyProduct(producto, pos); } else { //String nombre = txt_Nombre.Text; //String telefono = txt_Telefono.Text; //DateTime fechaAlta = (DateTime)txt_fechaAlta.SelectedDate; //User user = new User(nombre, telefono, fechaAlta); productoHandler.AddProduct(producto); } MainWindow.myNavigationFrame.NavigationService.Navigate(new MainPage()); }