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);
            }
        }
Exemplo n.º 2
0
        public static void CreatePermit(Record record, ref List<string> errors)
        {
            // Check record object
            if (record == null)
            {
                errors.Add("Record cannot be null");
            }
            else if (record != null)
            {
                // Check that all integer inputs are positive and non-zero
                if (record.customer_id <= 0 || record.permit_type_id <= 0)
                {
                    errors.Add("Invalid integer input.");
                }

                // Check that valid field of permit is set to true
                if (record.valid == false)
                {
                    errors.Add("Initial valid value must be true.");
                }

                List<Violation> violations = BLViolations.GetCustomerViolations(record.customer_id.ToString(), ref errors);
                if (violations != null)
                {
                    for (int i = 0; i < violations.Count; i++)
                    {
                        if (violations[i].paid == false)
                        {
                            errors.Add("Record has unpaid violation");
                            break;
                        }
                    }
                }
            }

            //TODO: regex matching for date input

            // Return if any errors exist
            if (errors.Count > 0)
            {
                AsynchLog.LogNow(errors);
                return;
            }

            record.permit_id = DALRecords.CreatePermit(record, ref errors);
        }
        public void CreatePermitTest()
        {
            //connections variables and dataset
            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 check = DALRecords.GetPermitInfo(customer.customer_id, ref errors);

                //remember to create get permit record based on customer id
                Assert.AreEqual(0, errors.Count);
                Assert.AreEqual(record.permit_id, check.permit_id);
                Assert.AreEqual(record.customer_id, check.customer_id);
                Assert.AreEqual(record.permit_type_id, check.permit_type_id);
                Assert.AreEqual(record.expire_date, check.expire_date);
                Assert.AreEqual(record.valid, check.valid);
            }
        }
Exemplo n.º 4
0
        public static int CreatePermit(Record record, ref List<string> errors)
        {
            //connections variables and dataset
            SqlConnection conn = new SqlConnection(connection_string);
            string permitId = string.Empty;
            try
            {
                string strSql = "createPermit";
                SqlDataAdapter adapter = new SqlDataAdapter(strSql, conn);
                DataSet dS = new DataSet();

                //add parameters to adapter
                adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                adapter.SelectCommand.Parameters.Add(new SqlParameter("@CustomerId", SqlDbType.Int));
                adapter.SelectCommand.Parameters.Add(new SqlParameter("@PermitTypeId", SqlDbType.Int));
                adapter.SelectCommand.Parameters.Add(new SqlParameter("@ExpireDate", SqlDbType.DateTime));
                adapter.SelectCommand.Parameters.Add(new SqlParameter("@Valid", SqlDbType.Bit));
                adapter.SelectCommand.Parameters["@CustomerId"].Value = record.customer_id;
                adapter.SelectCommand.Parameters["@PermitTypeId"].Value = record.permit_type_id;
                adapter.SelectCommand.Parameters["@ExpireDate"].Value = record.expire_date;
                adapter.SelectCommand.Parameters["@Valid"].Value = record.valid;

                adapter.Fill(dS, "result_table");
                permitId = dS.Tables["result_table"].Rows[0][0].ToString();
            }
            catch (Exception e)
            {
                errors.Add("Error: " + e.ToString());
            }
            finally
            {
                conn.Dispose();
                conn = null;
            }
            int retId;
            Int32.TryParse(permitId, out retId);
            return retId;
        }
Exemplo n.º 5
0
        public static void UpdateRecordTable(Record record, ref List<string> errors)
        {
            // Check record object
            if (record == null)
            {
                errors.Add("Record cannot be null");
            }

            // Check that all integer inputs are positive and non-zero
            if (record != null)
            {
                if (record.customer_id <= 0)
                {
                    errors.Add("Invalid customer id.");
                }

                //TODO: regex matching for date input

                // Check that valid field of permit is set to true
                if (!(record.valid == false || record.valid == true))
                {
                    errors.Add("Invalid boolean value.");
                }
            }

            // Return if any errors exist
            if (errors.Count > 0)
            {
                AsynchLog.LogNow(errors);
                return;
            }

            DALRecords.UpdateRecordTable(record, ref errors);
        }
        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 CreatePermitTest()
        {
            List<string> errors = new List<string>();
            BLRecords.CreatePermit(null, ref errors);
            Assert.AreEqual(1, errors.Count);

            errors = new List<string>();

            Record record = new Record();
            record.customer_id = -1;
            record.permit_type_id = 1;
            record.valid = false;
            BLRecords.CreatePermit(record, ref errors);
            Assert.AreEqual(3, errors.Count);
        }
        public void UpdateRecordTableTest()
        {
            List<string> errors = new List<string>();
            BLRecords.UpdateRecordTable(null, ref errors);
            Assert.AreEqual(1, errors.Count);

            errors = new List<string>();

            Record record = new Record();
            record.customer_id = -1;
            BLRecords.UpdateRecordTable(record, ref errors);
            Assert.AreEqual(1, errors.Count);
        }
Exemplo n.º 10
0
        public static Record GetPermitInfo(int customerId, ref List<string> errors)
        {
            //connections variables and dataset
            SqlConnection conn = new SqlConnection(connection_string);
            DataSet dS = new DataSet();
            Record record = new Record();
            try
            {
                string strSql = "getPermitInfo";
                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 > 1)
            {
                errors.Add("Multiple results");
                return null;
            }
            if (dS.Tables["result_table"].Rows.Count == 0)
            {
                return null;
            }
            else
            {
                record.permit_id = (int)dS.Tables["result_table"].Rows[0]["permit_id"];
                record.customer_id = (int) dS.Tables["result_table"].Rows[0]["customer_id"];
                record.permit_type_id = (int) dS.Tables["result_table"].Rows[0]["permit_type_id"];
                record.expire_date = (DateTime)dS.Tables["result_table"].Rows[0]["expire_date"];
                record.valid = (bool) dS.Tables["result_table"].Rows[0]["valid"];
                return record;
            }
        }
Exemplo n.º 11
0
        public static void UpdateRecordTable(Record record, ref List<string> errors)
        {
            //connections variables and dataset
            SqlConnection conn = new SqlConnection(connection_string);
            try
            {
                string strSql = "updateRecordTable";
                SqlDataAdapter adapter = new SqlDataAdapter(strSql, conn);
                DataSet dS = new DataSet();

                //add parameters to adapter
                adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                adapter.SelectCommand.Parameters.Add("@CustomerId", SqlDbType.Int);
                adapter.SelectCommand.Parameters.Add("@ExpireDate", SqlDbType.DateTime);
                adapter.SelectCommand.Parameters.Add("@Valid", SqlDbType.Bit);
                adapter.SelectCommand.Parameters["@CustomerId"].Value = record.customer_id;
                adapter.SelectCommand.Parameters["@ExpireDate"].Value = record.expire_date;
                adapter.SelectCommand.Parameters["@Valid"].Value = record.valid;
                adapter.Fill(dS, "result_table");

            }
            catch (Exception e)
            {
                errors.Add("Error: " + e.ToString());
            }
            finally
            {
                conn.Dispose();
                conn = null;
            }
        }
Exemplo n.º 12
0
 public void UpdateRecordTable(Record record, ref List<string> errors)
 {
     BLRecords.UpdateRecordTable(record, ref errors);
 }
Exemplo n.º 13
0
 public void CreatePermit(Record record, ref List<string> errors)
 {
     BLRecords.CreatePermit(record ,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);

            }
        }