public void Add_ProductNull_ThrowsException()
        {
            // Arrange
            ProductHandler productHandler = new ProductHandler();
            Product        product        = null;

            // Act
            // Assert
            Assert.ThrowsException <ArgumentNullException>(() => productHandler.Add(product));
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                pointReferences();

                aProduct.ID    = productH.Add(aProduct);
                label_Add.Text = Convert.ToString(aProduct.ID);

                MessageBox.Show("Added", "Data Entry Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                clearControls();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Data Entry Error - Unhandled", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void Add_ProductCorrectEntity_ReturnId()
        {
            // Arrange
            ProductProvider productProvider = new ProductProvider();
            var             allProducts     = productProvider.GetAll().OrderByDescending(p => p.Id);
            Product         lastProduct     = allProducts.FirstOrDefault() ?? new Product();

            ProductHandler productHandler = new ProductHandler();
            Product        product        = new Product();

            product.Name        = "Name";
            product.Description = "Description";
            product.Price       = 123.45m;
            // Act
            int id = productHandler.Add(product);

            // Assert
            Assert.IsTrue(lastProduct.Id < id);
        }
Exemple #4
0
        // BUTTON EVENT FIRES
        protected void add_button_Click(object sender, EventArgs e)
        {
            notificationSuccess_label.Text = "";
            notificationError_label.Text   = "";
            success_box.Visible            = false;
            error_box.Visible = false;
            if (inputWatchName_textBox.Text != "" && !isImageInCorrectFormat() && inputUserWatchPrice_textBox.Text != "" && Int32.Parse(inputUserWatchQuantity_textBox.Text) > 0)
            {
                int    quantity = Int32.Parse(inputUserWatchQuantity_textBox.Text);
                string image    = getImageUploaded();

                ProductHandler.Add(inputWatchName_textBox.Text, image, Convert.ToDecimal(inputUserWatchPrice_textBox.Text), quantity);
                success_box.Visible            = true;
                notificationSuccess_label.Text = "Add Watch Successful";
                notificationError_label.Text   = "";

                //clearAllInput();
            }
            else
            {
                checkEmptiness();
            }
        }