Exemplo n.º 1
0
        public static void UpdateAmountViolation(Violation violation, ref List<string> errors)
        {
            if (violation == null)
            {
                errors.Add("Invalid violation");
            }

            DALViolations.UpdateAmountViolation(violation, ref errors);
        }
Exemplo n.º 2
0
 public static void CreateViolation(Violation violation, ref List<string> errors)
 {
     if (violation == null)
     {
         errors.Add("Violation cannot be null");
     }
     if (errors.Count > 0)
         return;
     violation.violation_id = DALViolations.CreateViolation(violation, ref errors);
 }
        public void CreatePermitErrorTest()
        {
            Customer customer = new Customer();
            customer.customer_name = "bltestcreatecustomer";
            customer.customer_pw = "fakepassword1"; // TODO: Initialize to an appropriate value
            customer.customer_type = "undertest";
            customer.first_name = "test"; // TODO: Initialize to an appropriate value
            customer.middle_name = "test"; // TODO: Initialize to an appropriate value
            customer.last_name = "test"; // TODO: Initialize to an appropriate value
            List<string> errors = new List<string>();
            using (var scop = new System.Transactions.TransactionScope())
            {
                BLCustomers.CreateCustomer(customer, ref errors);

                Permit permit = new Permit();
                permit.permit_name = "bl customertest";
                permit.customer_type = "undergrad";
                permit.price = 50;
                permit.v_description = "test";
                BLPermitTypes.CreatePermitType(permit, ref errors);

                Record record = new Record();
                record.customer_id = customer.customer_id;
                record.permit_type_id = permit.id;
                record.expire_date = DateTime.Parse("11/11/2011");
                record.valid = true;
                BLRecords.CreatePermit(record, ref errors);

                Violation violation = new Violation();
                violation.permit_id = record.permit_id;
                violation.fee = 48;
                violation.v_description = "testing create violations - test1";
                violation.violation_date = DateTime.Parse("11/11/2011");
                violation.paid = false;
                BLViolations.CreateViolation(violation, ref errors);

                Record record1 = new Record();
                record1.customer_id = customer.customer_id;
                record1.permit_type_id = permit.id;
                record1.expire_date = DateTime.Parse("11/11/2011");
                record1.valid = true;
                BLRecords.CreatePermit(record1, ref errors);

                Assert.AreEqual(1, errors.Count);
            }
        }
        public static int CreateViolation(Violation violation, ref List<string> errors)
        {
            SqlConnection conn = new SqlConnection(connection_string);
            string violationId = string.Empty;
            try
            {
                string strSQL = "createViolation";
                SqlDataAdapter mySA = new SqlDataAdapter(strSQL, conn);
                DataSet myDS = new DataSet();
                mySA.SelectCommand.CommandType = CommandType.StoredProcedure;
                mySA.SelectCommand.Parameters.Add(new SqlParameter("@permitId", SqlDbType.Int));
                mySA.SelectCommand.Parameters.Add(new SqlParameter("@Fee", SqlDbType.Int));
                mySA.SelectCommand.Parameters.Add(new SqlParameter("@ViolationDate", SqlDbType.DateTime));
                mySA.SelectCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.VarChar, 200));
                mySA.SelectCommand.Parameters.Add(new SqlParameter("@Paid", SqlDbType.Bit));

                mySA.SelectCommand.Parameters["@permitId"].Value = violation.permit_id;
                mySA.SelectCommand.Parameters["@Fee"].Value = violation.fee;
                mySA.SelectCommand.Parameters["@ViolationDate"].Value = violation.violation_date;
                mySA.SelectCommand.Parameters["@Description"].Value = violation.v_description;
                mySA.SelectCommand.Parameters["@Paid"].Value = violation.paid;

                mySA.Fill(myDS, "result_table");
                violationId = myDS.Tables["result_table"].Rows[0][0].ToString();

            }
            catch (Exception e)
            {
                errors.Add("Error: " + e.ToString());
            }
            finally
            {
                conn.Dispose();
                conn = null;
            }
            int retId;
            Int32.TryParse(violationId, out retId);
            return retId;
        }
        public static List<Violation> GetCustomerViolations(int customerId, ref List<string> errors)
        {
            //connections variables and dataset
            SqlConnection conn = new SqlConnection(connection_string);
            DataSet dS = new DataSet();
            List<Violation> violations = new List<Violation>();
            try
            {
                string strSql = "getCustomerViolations";
                SqlDataAdapter adapter = new SqlDataAdapter(strSql, conn);

                adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                adapter.SelectCommand.Parameters.Add("@CustomerId", SqlDbType.Int);
                adapter.SelectCommand.Parameters["@CustomerId"].Value = customerId;
                adapter.Fill(dS, "result_table");
            }
            catch (Exception e)
            {
                errors.Add("Error: " + e.ToString());
            }
            finally
            {
                conn.Dispose();
                conn = null;
            }
            if (dS.Tables["result_table"].Rows.Count == 0)
            {
                return null;
            }
            else
            {
                foreach (DataRow row in dS.Tables["result_table"].Rows)
                {
                    Violation vio = new Violation();
                    vio.violation_id =(int) row["violation_id"];
                    vio.permit_id = (int)row["permit_id"];
                    vio.fee = (int)row["fee"];
                    vio.paid = (bool)row["paid"];
                    vio.v_description = (string)row["v_description"];
                    vio.violation_date = (DateTime)row["violation_date"];
                    violations.Add(vio);
                }
                return violations;
            }
        }
        public static void UpdateAmountViolation(Violation violation, ref List<string> errors)
        {
            SqlConnection conn = new SqlConnection(connection_string);
            try
            {
                string strSQL = "updateAmountViolation";
                SqlDataAdapter mySA = new SqlDataAdapter(strSQL, conn);
                mySA.SelectCommand.CommandType = CommandType.StoredProcedure;
                mySA.SelectCommand.Parameters.Add(new SqlParameter("@Violation_id", SqlDbType.Int));
                mySA.SelectCommand.Parameters.Add(new SqlParameter("@Amount", SqlDbType.Int));

                mySA.SelectCommand.Parameters["@Violation_id"].Value = violation.violation_id;
                mySA.SelectCommand.Parameters["@Amount"].Value = violation.fee;

                DataSet myDS = new DataSet();
                mySA.Fill(myDS);

            }
            catch (Exception e)
            {
                errors.Add("Error: " + e.ToString());
            }
            finally
            {
                conn.Dispose();
                conn = null;
            }
        }
 public static List<Violation> ListViolations(ref List<string> errors)
 {
     {
         SqlConnection conn = new SqlConnection(connection_string);
         List<Violation> violations = new List<Violation>();
         DataSet dS = new DataSet();
         try
         {
             string strSQL = "listViolations";
             SqlDataAdapter mySA = new SqlDataAdapter(strSQL, conn);
             mySA.SelectCommand.CommandType = CommandType.StoredProcedure;
             mySA.Fill(dS, "result_table");
             for (int i =0;i<dS.Tables["result_table"].Rows.Count;i++)
             {
                 Violation violation = new Violation();
                 violation.violation_id = (int)dS.Tables["result_table"].Rows[i]["violation_id"];
                 violation.permit_id = (int)dS.Tables["result_table"].Rows[i]["permit_id"];
                 violation.fee = (int)dS.Tables["result_table"].Rows[i]["fee"];
                 violation.violation_date = (DateTime)dS.Tables["result_table"].Rows[i]["violation_date"];
                 violation.v_description = dS.Tables["result_table"].Rows[i]["v_description"].ToString();
                 violation.paid = (bool)dS.Tables["result_table"].Rows[i]["paid"];
                 violations.Add(violation);
             }
         }
         catch (Exception e)
         {
             errors.Add("Error: " + e.ToString());
         }
         finally
         {
             conn.Dispose();
             conn = null;
         }
         return violations;
     }
 }
        public static Violation GetViolationById(int violation_id, ref List<string> errors)
        {
            SqlConnection conn = new SqlConnection(connection_string);
            Violation violation = new Violation();
            DataSet dS = new DataSet();
            try
            {
                string strSQL = "getViolationById";
                SqlDataAdapter mySA = new SqlDataAdapter(strSQL, conn);
                mySA.SelectCommand.CommandType = CommandType.StoredProcedure;
                mySA.SelectCommand.Parameters.Add(new SqlParameter("@ViolationId", SqlDbType.Int));
                mySA.SelectCommand.Parameters["@ViolationId"].Value = violation_id;
                mySA.Fill(dS, "result_table");
            }
            catch (Exception e)
            {
                errors.Add("Error: " + e.ToString());
            }
            finally
            {
                conn.Dispose();
                conn = null;
            }
            if (dS.Tables["result_table"].Rows.Count > 1)
            {
                errors.Add("Multiple results");
                return null;
            }
            if (dS.Tables["result_table"].Rows.Count == 0)
            {
                return null;
            }
            else
            {
                violation.violation_id = (int)dS.Tables["result_table"].Rows[0]["violation_id"];
                violation.permit_id = (int)dS.Tables["result_table"].Rows[0]["permit_id"];
                violation.fee = (int)dS.Tables["result_table"].Rows[0]["fee"];
                violation.violation_date = (DateTime)dS.Tables["result_table"].Rows[0]["violation_date"];
                violation.v_description = dS.Tables["result_table"].Rows[0]["v_description"].ToString();
                violation.paid = (bool)dS.Tables["result_table"].Rows[0]["paid"];

                return violation;
            }
        }
        public void createViolationTest()
        {
            List<string> errors = new List<string>();
            using (var scop = new System.Transactions.TransactionScope())
            {
                Customer customer = new Customer();
                customer.customer_name = "create record test";
                customer.customer_pw = "test";
                customer.customer_type = "test";
                customer.first_name = "test";
                customer.middle_name = "test";
                customer.last_name = "test";
                customer.customer_id = DALCustomers.CreateCustomer(customer, ref errors);

                Permit permit = new Permit();
                permit.permit_name = "create record test";
                permit.customer_type = "test";
                permit.price = 50;
                permit.v_description = "test";
                permit.id = DALPermitTypes.CreatePermitType(permit, ref errors);

                Record record = new Record();
                record.customer_id = customer.customer_id;
                record.permit_type_id = permit.id;
                record.expire_date = DateTime.Parse("11/11/2011");
                record.valid = true;
                record.permit_id = DALRecords.CreatePermit(record, ref errors);
                Record r_check = DALRecords.GetPermitInfo(customer.customer_id, ref errors);

                Violation violation = new Violation();
                violation.permit_id = record.permit_id;
                violation.fee = 48;
                violation.v_description = "testing create violations - test1";
                violation.violation_date = DateTime.Parse("11/11/2011");
                violation.paid = true;
                violation.violation_id = DALViolations.CreateViolation(violation, ref errors);

                Violation violation2 = new Violation();
                violation2.permit_id = record.permit_id;
                violation2.fee = 100;
                violation2.v_description = "testing create violations - test2";
                violation2.violation_date = DateTime.Parse("11/11/2011");
                violation2.paid = false;
                violation2.violation_id = DALViolations.CreateViolation(violation2, ref errors);

                List<Violation> check = DALViolations.GetCustomerViolations(record.customer_id, ref errors);
                Violation check_single_vio = DALViolations.GetViolationById(violation.violation_id, ref errors);

                Assert.AreEqual(0, errors.Count);
                Assert.AreNotEqual(0, check.Count);
                bool pass = false;

                Assert.AreEqual(violation.violation_id, check_single_vio.violation_id);
                Assert.AreEqual(violation.permit_id, check_single_vio.permit_id);
                Assert.AreEqual(violation.fee, check_single_vio.fee);
                Assert.AreEqual(violation.paid, check_single_vio.paid);
                Assert.AreEqual(violation.v_description, check_single_vio.v_description);
                Assert.AreEqual(violation.violation_date, check_single_vio.violation_date);
                foreach (Violation v in check)
                {
                    Assert.AreEqual(violation.permit_id, v.permit_id);
                    Assert.AreEqual(violation2.permit_id, v.permit_id);
                    if (v.violation_id == violation.violation_id)
                    {
                        //Assert.AreEqual(violation.violation_id, v.violation_id);
                        Assert.AreEqual(violation.fee, v.fee);
                        Assert.AreEqual(violation.paid, v.paid);
                        Assert.AreEqual(violation.v_description, v.v_description);
                        Assert.AreEqual(violation.violation_date, v.violation_date);
                        pass = true;
                    }
                    if (v.violation_id == violation2.violation_id)
                    {
                        //Assert.AreEqual(violation.violation_id, v.violation_id);
                        Assert.AreEqual(violation2.fee, v.fee);
                        Assert.AreEqual(violation2.paid, v.paid);
                        Assert.AreEqual(violation2.v_description, v.v_description);
                        Assert.AreEqual(violation2.violation_date, v.violation_date);
                        pass = true;
                    }
                }
                Assert.AreEqual(true, pass);
            }
        }
        public void ListViolationsTest()
        {
            List<string> errors = new List<string>();
            using (var scop = new System.Transactions.TransactionScope())
            {
                Customer customer = new Customer();
                customer.customer_name = "create record test";
                customer.customer_pw = "test";
                customer.customer_type = "test";
                customer.first_name = "test";
                customer.middle_name = "test";
                customer.last_name = "test";
                customer.customer_id = DALCustomers.CreateCustomer(customer, ref errors);

                Permit permit = new Permit();
                permit.permit_name = "create record test";
                permit.customer_type = "test";
                permit.price = 50;
                permit.v_description = "test";
                permit.id = DALPermitTypes.CreatePermitType(permit, ref errors);

                Record record = new Record();
                record.customer_id = customer.customer_id;
                record.permit_type_id = permit.id;
                record.expire_date = DateTime.Parse("11/11/2011");
                record.valid = true;
                record.permit_id = DALRecords.CreatePermit(record, ref errors);
                Record r_check = DALRecords.GetPermitInfo(customer.customer_id, ref errors);

                Violation violation = new Violation();
                violation.permit_id = record.permit_id;
                violation.fee = 48;
                violation.v_description = "testing create violations - test1";
                violation.violation_date = DateTime.Parse("11/11/2011");
                violation.paid = false;
                violation.violation_id = DALViolations.CreateViolation(violation, ref errors);

                Violation violation2 = new Violation();
                violation2.permit_id = record.permit_id;
                violation2.fee = 48;
                violation2.v_description = "testing create violations - test1";
                violation2.violation_date = DateTime.Parse("11/11/2011");
                violation2.paid = false;
                violation2.violation_id = DALViolations.CreateViolation(violation2, ref errors);

                List<Violation> expected_violations = new List<Violation>();
                expected_violations.Add(violation);
                expected_violations.Add(violation2);
                List<Violation> check = DALViolations.ListViolations(ref errors);

                Assert.AreEqual(0, errors.Count);
                for (int i = 0;i<expected_violations.Count;i++)
                {
                    Assert.AreEqual(expected_violations[i].violation_id, check[i].violation_id);
                    Assert.AreEqual(expected_violations[i].permit_id, check[i].permit_id);
                    Assert.AreEqual(expected_violations[i].fee, check[i].fee);
                    Assert.AreEqual(expected_violations[i].violation_date, check[i].violation_date);
                    Assert.AreEqual(expected_violations[i].v_description, check[i].v_description);
                    Assert.AreEqual(expected_violations[i].paid, check[i].paid);
                }
            }
        }
 public void UpdateAmountViolation(Violation violation, ref List<string> errors)
 {
     BLViolations.UpdateAmountViolation(violation, ref errors);
 }
 public void CreateViolation(Violation violation, ref List<string> errors)
 {
     BLViolations.CreateViolation(violation, ref errors);
 }
        public void getCustomerInvoiceHistoryTest()
        {
            //connections variables and dataset
            SqlConnection conn = new SqlConnection(connection_string);
            List<string> errors = new List<string>();
            using (var scop = new System.Transactions.TransactionScope())
            {
                Customer customer = new Customer();
                customer.customer_name = "get customer invoice";
                customer.customer_pw = "test";
                customer.customer_type = "test";
                customer.first_name = "test";
                customer.middle_name = "test";
                customer.last_name = "test";
                customer.customer_id = DALCustomers.CreateCustomer(customer, ref errors);

                Permit permit = new Permit();
                permit.permit_name = "get customer invoice1";
                permit.customer_type = "test";
                permit.price = 50;
                permit.v_description = "test";
                permit.id = DALPermitTypes.CreatePermitType(permit, ref errors);

                Record record = new Record();
                record.customer_id = customer.customer_id;
                record.permit_type_id = permit.id;
                record.expire_date = DateTime.Parse("11/11/2011");
                record.valid = true;
                record.permit_id = DALRecords.CreatePermit(record, ref errors);

                Violation violation1 = new Violation();
                violation1.permit_id = record.permit_id;
                violation1.fee = 48;
                violation1.v_description = "testing create violation1s - test1";
                violation1.violation_date = DateTime.Parse("11/11/2011");
                violation1.paid = true;
                violation1.violation_id = DALViolations.CreateViolation(violation1, ref errors);

                Violation violation2 = new Violation();
                violation2.permit_id = record.permit_id;
                violation2.fee = 100;
                violation2.v_description = "testing create violations - test2";
                violation2.violation_date = DateTime.Parse("11/11/2011");
                violation2.paid = false;
                violation2.violation_id = DALViolations.CreateViolation(violation2, ref errors);

                Invoice invoice1 = new Invoice();
                invoice1.invoice_type = "getcustomerinvoice1";
                invoice1.customer_id = customer.customer_id;
                invoice1.item_id = record.permit_id;
                invoice1.amt_paid = 200;
                invoice1.pay_method = "visa";
                invoice1.pay_date = DateTime.Parse("11/11/2011");
                invoice1.invoice_id = DALInvoices.CreateInvoice(invoice1, ref errors);

                Invoice invoice2 = new Invoice();
                invoice2.invoice_type = "getcustomerinvoie2";
                invoice2.customer_id = customer.customer_id;
                invoice2.item_id = violation1.violation_id;
                invoice2.amt_paid = 200;
                invoice2.pay_method = "visa";
                invoice2.pay_date = DateTime.Parse("11/11/2011");
                invoice2.invoice_id = DALInvoices.CreateInvoice(invoice2, ref errors);

                Invoice invoice3 = new Invoice();
                invoice3.invoice_type = "getcustomerinvoice3";
                invoice3.customer_id = customer.customer_id;
                invoice3.item_id = 500;
                invoice3.amt_paid = 200;
                invoice3.pay_method = "visa";
                invoice3.pay_date = DateTime.Parse("11/11/2011");
                invoice3.invoice_id = DALInvoices.CreateInvoice(invoice3, ref errors);

                List<Invoice> exepectedInvoices = new List<Invoice>();
                exepectedInvoices.Add(invoice1); exepectedInvoices.Add(invoice2); exepectedInvoices.Add(invoice3);
                List<Invoice> check = DALCustomers.getCustomerInvoiceHistory(customer.customer_id, ref errors);
                int index = 0;
                Assert.AreEqual(0, errors.Count);
                foreach (Invoice i in exepectedInvoices)
                {
                    Assert.AreEqual(i.invoice_id, check[index].invoice_id);
                    Assert.AreEqual(i.invoice_type, check[index].invoice_type);
                    Assert.AreEqual(i.customer_id, check[index].customer_id);
                    Assert.AreEqual(i.item_id, check[index].item_id);
                    Assert.AreEqual(i.amt_paid, check[index].amt_paid);
                    Assert.AreEqual(i.pay_method, check[index].pay_method);
                    Assert.AreEqual(i.pay_date, check[index].pay_date);
                    index++;
                }
            }
        }
        public void CreateCustomerTest()
        {
            Customer customer = new Customer();
            List<string> errors = new List<string>();
            customer.customer_name = "bltestcreatecustomer";
            customer.customer_pw = "fakepassword1"; // TODO: Initialize to an appropriate value
            customer.customer_type = "undergrad";
            customer.first_name = "test"; // TODO: Initialize to an appropriate value
            customer.middle_name = "test"; // TODO: Initialize to an appropriate value
            customer.last_name = "test"; // TODO: Initialize to an appropriate value
            Customer check = new Customer();
            using (var scop = new System.Transactions.TransactionScope())
            {
                //insert
                BLCustomers.CreateCustomer(customer, ref errors);
                //check = BLCustomers.GetCustomerInfo(customer.customer_id.ToString(), ref errors);
                check = BLCustomers.CheckCustomerLoginPassword(customer.customer_name, customer.customer_pw, ref errors);
                Assert.AreEqual(0, errors.Count);
                Assert.IsNotNull(check);
                Assert.AreEqual(customer.customer_id, check.customer_id);
                Assert.AreEqual(customer.customer_name, check.customer_name);
                Assert.AreEqual(customer.customer_pw, check.customer_pw);
                Assert.AreEqual(customer.customer_type, check.customer_type);
                Assert.AreEqual(customer.first_name, check.first_name);
                Assert.AreEqual(customer.middle_name, check.middle_name);
                Assert.AreEqual(customer.last_name, check.last_name);

                //update test
                customer.customer_pw = "fakepassword1"; // TODO: Initialize to an appropriate value
                customer.first_name = "updated BL "; // TODO: Initialize to an appropriate value
                customer.middle_name = "updated BL"; // TODO: Initialize to an appropriate value
                customer.last_name = "updated BL"; // TODO: Initialize to an appropriate value
                BLCustomers.UpdateCustomer(customer, ref errors);
                check = BLCustomers.GetCustomerInfo(customer.customer_id.ToString(), ref errors);
                Assert.AreEqual(0, errors.Count);
                Assert.IsNotNull(check);
                Assert.AreEqual(customer.customer_id, check.customer_id);
                Assert.AreEqual(customer.customer_name, check.customer_name);
                Assert.AreEqual(customer.customer_pw, check.customer_pw);
                Assert.AreEqual(customer.customer_type, check.customer_type);
                Assert.AreEqual(customer.first_name, check.first_name);
                Assert.AreEqual(customer.middle_name, check.middle_name);
                Assert.AreEqual(customer.last_name, check.last_name);

                //delete test
                BLCustomers.DeleteCustomer(customer.customer_id.ToString(), ref errors);
                check = BLCustomers.GetCustomerInfo(customer.customer_id.ToString(), ref errors);
                Assert.AreEqual(0, errors.Count);
                Assert.IsNull(check);

                //get record, invoice and violation test
                BLCustomers.CreateCustomer(customer, ref errors);

                Permit permit = new Permit();
                permit.permit_name = "bl customertest";
                permit.customer_type = "undergrad";
                permit.price = 50;
                permit.v_description = "test";
                BLPermitTypes.CreatePermitType(permit, ref errors);

                Record record = new Record();
                record.customer_id = customer.customer_id;
                record.permit_type_id = permit.id;
                record.expire_date = DateTime.Parse("11/11/2011");
                record.valid = true;
                BLRecords.CreatePermit(record, ref errors);

                Invoice invoice1 = new Invoice();
                invoice1.invoice_type = "purchase";
                invoice1.customer_id = customer.customer_id;
                invoice1.item_id = record.permit_id;
                invoice1.amt_paid = 200;
                invoice1.pay_method = "debit";
                invoice1.pay_date = DateTime.Parse("11/11/2011");
                BLInvoices.CreateInvoice(invoice1, ref errors);

                Violation violation = new Violation();
                violation.permit_id = record.permit_id;
                violation.fee = 48;
                violation.v_description = "testing create violations - test1";
                violation.violation_date = DateTime.Parse("11/11/2011");
                violation.paid = false;
                BLViolations.CreateViolation(violation, ref errors);

                Invoice invoice2 = new Invoice();
                invoice2.invoice_type = "violation";
                invoice2.customer_id = customer.customer_id;
                //invoice2.item_id = violation.violation_id;
                invoice2.item_id = 500;
                invoice2.amt_paid = 220;
                invoice2.pay_method = "debit";
                invoice2.pay_date = DateTime.Parse("11/11/2011");
                BLInvoices.CreateInvoice(invoice2, ref errors);

                List<Violation> expected_violations = new List<Violation>();
                expected_violations.Add(violation);
                List<Violation> violations = BLViolations.GetCustomerViolations(record.customer_id.ToString(), ref errors);
                for (int index = 0; index < expected_violations.Count; index++)
                {
                    Assert.AreEqual(violations[index].permit_id, expected_violations[index].permit_id);
                    Assert.AreEqual(violations[index].fee, expected_violations[index].fee);
                    Assert.AreEqual(violations[index].v_description, expected_violations[index].v_description);
                    Assert.AreEqual(violations[index].violation_date, expected_violations[index].violation_date);
                    Assert.AreEqual(violations[index].paid, expected_violations[index].paid);
                }
                List<Invoice> expected_invoices = new List<Invoice>();
                expected_invoices.Add(invoice1);
                expected_invoices.Add(invoice2);
                List<Invoice> invoices = new List<Invoice>();
                invoices = BLCustomers.GetCustomerInvoiceHistory(customer.customer_id.ToString(), ref errors);

                Assert.AreEqual(0, errors.Count);
                for (int index = 0; index < expected_invoices.Count; index++)
                {
                    Assert.AreEqual(expected_invoices[index].invoice_id, invoices[index].invoice_id);
                    Assert.AreEqual(expected_invoices[index].invoice_type, invoices[index].invoice_type);
                    Assert.AreEqual(expected_invoices[index].customer_id, invoices[index].customer_id);
                    Assert.AreEqual(expected_invoices[index].item_id, invoices[index].item_id);
                    Assert.AreEqual(expected_invoices[index].amt_paid, invoices[index].amt_paid);
                    Assert.AreEqual(expected_invoices[index].pay_method, invoices[index].pay_method);
                    Assert.AreEqual(expected_invoices[index].pay_date, invoices[index].pay_date);
                }

                //update record and invoice test
                record.valid = false;
                BLRecords.UpdateRecordTable(record, ref errors);
                violation.fee = 250;
                violation.paid = true;
                BLViolations.UpdateAmountViolation(violation, ref errors);
                BLViolations.UpdatePayViolation(violation.violation_id.ToString(), ref errors);

                expected_violations = new List<Violation>();
                expected_violations.Add(violation);
                violations = BLViolations.GetCustomerViolations(record.customer_id.ToString(), ref errors);
                for (int index = 0; index < expected_violations.Count; index++)
                {
                    Assert.AreEqual(violations[index].permit_id, expected_violations[index].permit_id);
                    Assert.AreEqual(violations[index].fee, expected_violations[index].fee);
                    Assert.AreEqual(violations[index].v_description, expected_violations[index].v_description);
                    Assert.AreEqual(violations[index].violation_date, expected_violations[index].violation_date);
                    Assert.AreEqual(violations[index].paid, expected_violations[index].paid);
                }

                //update invoice test
                invoice2.amt_paid = 110;
                invoice2.pay_method = "credit";
                invoice2.pay_date = DateTime.Parse("12/11/2011");
                BLInvoices.UpdateInvoiceTable(invoice2, ref errors);

                expected_invoices = new List<Invoice>();
                expected_invoices.Add(invoice1);
                expected_invoices.Add(invoice2);
                invoices = new List<Invoice>();
                invoices = BLCustomers.GetCustomerInvoiceHistory(customer.customer_id.ToString(), ref errors);

                Assert.AreEqual(0, errors.Count);
                for (int index = 0; index < expected_invoices.Count; index++)
                {
                    Assert.AreEqual(expected_invoices[index].invoice_id, invoices[index].invoice_id);
                    Assert.AreEqual(expected_invoices[index].invoice_type, invoices[index].invoice_type);
                    Assert.AreEqual(expected_invoices[index].customer_id, invoices[index].customer_id);
                    Assert.AreEqual(expected_invoices[index].item_id, invoices[index].item_id);
                    Assert.AreEqual(expected_invoices[index].amt_paid, invoices[index].amt_paid);
                    Assert.AreEqual(expected_invoices[index].pay_method, invoices[index].pay_method);
                    Assert.AreEqual(expected_invoices[index].pay_date, invoices[index].pay_date);
                }

                //getpermit based on customer level test
                System.Diagnostics.Debug.WriteLine(customer.customer_id);
                Permit check_permit = BLPermitTypes.GetPermitsBasedOnCustomer(record.customer_id.ToString(), ref errors);
                Assert.AreEqual(0, errors.Count);
                Assert.AreEqual(permit.id, check_permit.id);
                Assert.AreEqual(permit.permit_name, check_permit.permit_name);
                Assert.AreEqual(permit.customer_type, check_permit.customer_type);
                Assert.AreEqual(permit.price, check_permit.price);
                Assert.AreEqual(permit.v_description, check_permit.v_description);

                //getpermit list
                List<Permit> permits = BLPermitTypes.GetPermitsList(ref errors);
                Assert.AreEqual(1, permits.Count);

            }
        }