public void WhenProductValuesAreChanged_TheDatabaseIsUpdated()
        {
            _crud.Create("change", 5, "changeURL");

            Product testProduct = _crud.GetProductByName("change");

            _crud.Update(testProduct, "newTest", 10, "testURL");

            Product newProduct = _crud.GetProductByName("newTest");

            Assert.That(newProduct, Is.Not.Null);
            Assert.That(newProduct.Name, Is.EqualTo("newTest"));
            Assert.That(newProduct.Price, Is.EqualTo(10));
            Assert.That(newProduct.Url, Is.EqualTo("testURL"));

            _crud.Delete(newProduct);
        }
示例#2
0
        private void button_update_Click(object sender, RoutedEventArgs e)
        {
            if (CrudProduct.Selected != null)
            {
                (bool, decimal)priceInput = validator.CheckDecimalInput(textBox_price_value.Text);

                if (!priceInput.Item1)
                {
                    MessageBox.Show("Price must be a numeric value");
                    return;
                }
                CrudProduct.Update(CrudProduct.Selected, textBox_name_value.Text, priceInput.Item2, textBox_URL_value.Text);
                MessageBox.Show($"Product: {textBox_name_value.Text} updated");
            }
            else
            {
                MessageBox.Show("Please select a product to update");
            }
        }