コード例 #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.");
        }