Exemplo n.º 1
0
        public void SaveEntryToDataBase()
        {
            double amount = 0;

            mainDBHelper.InitializeNewBillEntry("Suresh", true);
            mainDBHelper.UpdateCustomerName("Ram");
            mainDBHelper.UpdatePhoneNumber("9447586655");
            mainDBHelper.AddProduct("Selfie", out amount);
            mainDBHelper.UpdateBillType(2);
            mainDBHelper.UpdateDeliverStatus(true);
            int beforeCount = dbHelper.GetBillEntryCount();

            mainDBHelper.SaveEntryToDatabase();
            int afterCount = dbHelper.GetBillEntryCount();

            Assert.AreEqual(beforeCount + 1, afterCount, "Bill Entry not saved to the database");
            mainDBHelper.UpdateBillType(1);
            mainDBHelper.SaveEntryToDatabase();
            int currentCount = dbHelper.GetBillEntryCount();

            Assert.AreEqual(afterCount, currentCount, "Updating the entry should not add a record to the database.");
            BillEntry latestEntry = dbHelper.GetCustomer("Ram", "9447586655");

            Assert.IsNotNull(latestEntry, "Bill Entry should not be null");
            Assert.AreEqual(2, (int)latestEntry.BillType, "Updated value didn't get saved after save.");
        }
Exemplo n.º 2
0
        public void SaveCurrentEntry()
        {
            if (dbHelper.GetCustomerName() == "" || dbHelper.GetPhoneNumber() == "" || dbHelper.GetTotalAmount() == "0")
            {
                dialogHelper.ShowWarning("Customer Name or Phone Number or Product details missing", "Required!!!");
            }
            else if (dbHelper.GetBillType() == BillType.Undefined)
            {
                dialogHelper.ShowWarning("Select Bill Type", "Alert!!!");
            }
            else
            {
                bool isSaved = dbHelper.SaveEntryToDatabase();

                if (isSaved)
                {
                    dialogHelper.ShowInfo("Details Saved", "Success");
                }
                else
                {
                    dialogHelper.ShowInfo("Already Saved", "Info");
                }
            }
        }