public void DeletePurchaseTestMethod() { bool resAdd = PurchaseDbController.AddPurchase(11, 15.5, 5, "kg"); Assert.IsTrue(resAdd); List <Purchase> list = PurchaseDbController.GetPurchases(); int count = list.Count; bool resDel = PurchaseDbController.DeletePurchase(list[count - 1].Id); Assert.IsTrue(resDel); Assert.AreEqual(PurchaseDbController.GetPurchases().Count, --count); }
public void AddPurchaseTestMethod() { List <Purchase> list = PurchaseDbController.GetPurchases(); int count = list.Count; bool res = PurchaseDbController.AddPurchase(11, 15.5, 5, "kg"); Assert.IsTrue(res); Assert.AreEqual(PurchaseDbController.GetPurchases().Count, ++count); List <Purchase> resList = PurchaseDbController.GetPurchases(); Assert.AreEqual(resList[count - 1].IdProduct, 11); Assert.AreEqual(resList[count - 1].Quantity, 15.5); Assert.AreEqual(resList[count - 1].Price, 5); Assert.AreEqual(resList[count - 1].Unit, "kg"); }
private void AddButton_Click(object sender, EventArgs e) { if (textBoxProductId.Text != "" && textBoxQuantity.Text != "" && textBoxPrice.Text != "" && textBoxUnit.Text != "") { if (double.Parse(textBoxPrice.Text) > 0 && double.Parse(textBoxQuantity.Text) > 0) { PurchaseDbController.AddPurchase(int.Parse(textBoxProductId.Text), double.Parse(textBoxQuantity.Text), double.Parse(textBoxPrice.Text), textBoxUnit.Text); MessageBox.Show("Success"); } else { MessageBox.Show("Price/quantity can not be negative! Please try again)"); textBoxPrice.Text = ""; } } else { MessageBox.Show("All fields must be filled! Please try again)"); } }