コード例 #1
0
        public void WhenANewProductIsCreated_ItIsAddedToTheDatabase()
        {
            int originalNum = _crud.RetrieveAll <Product>().Count;

            _crud.Create("newTest", 10, "testURL");
            Assert.That(originalNum + 1, Is.EqualTo(_crud.RetrieveAll <Product>().Count));

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

            _crud.Delete(newProduct);
        }
コード例 #2
0
 private void button_delete_Click(object sender, RoutedEventArgs e)
 {
     if (CrudProduct.Selected != null)
     {
         CrudProduct.Delete(CrudProduct.Selected);
         MessageBox.Show($"Product: {textBox_name_value.Text} deleted");
         CrudProduct.Selected     = null;
         textBlock_productID.Text = string.Empty;
         textBox_name_value.Text  = string.Empty;
         textBox_price_value.Text = string.Empty;
         textBox_URL_value.Text   = string.Empty;
         CustomEvents.current.ProductDeleted();
     }
     else
     {
         MessageBox.Show("Please select a product to delete");
     }
 }