public void AddReport_ApprovedBySupAndApprovedByAcc_GetReportStatus() { DateTime date = DateTime.Now.Date; string reportName = "REPORT"; string location = "Broadway"; string description = "food"; string strAmount = "100.1111"; double amount = Math.Round(100.1111, 2); double amount_aud = 148.16; string currency = "Euros"; byte[] receipt = new byte[] { 2, 3, 4, 2 }; int reportId = GetCurrentRowOfReportsTable() + 1; int expenseId = GetCurrentRowOfExpensesTable() + 1; Consultant consultant = new Consultant("con_he5"); Supervisor supervisor = new Supervisor("sup_he1"); AccountsStaff accountsStaff = new AccountsStaff("acc1"); // start transaction using (TransactionScope testTransaction = new TransactionScope()) { consultant.CreateExpense(date, location, description, strAmount, currency, receipt); consultant.AddExpenses(reportId); consultant.AddReport(reportName); supervisor.Approve(reportId); accountsStaff.Approve(reportId); ReportsTableAdapter adapter = new ReportsTableAdapter(); Reports.ReportsDataTable reportsTable = new Reports.ReportsDataTable(); adapter.FillById(reportsTable, reportId); foreach (Reports.ReportsRow report in reportsTable) { Assert.AreEqual(reportId, report.Id); Assert.AreEqual(reportName, report.Report_name); Assert.AreEqual(amount, report.Total_amount); Assert.AreEqual("APPROVED", report.Supervisor_approval); Assert.AreEqual("APPROVED", report.Accounts_approval); Assert.AreEqual(consultant.Department, report.Department); Assert.AreEqual(consultant.Username, report.Consultant_id); Assert.AreEqual("NONE", report.Supervisor_id); } testTransaction.Dispose(); // rollback } }
public void AddReport_ApprovedBySupAndRejectedByAcc_GetReportStatus() { DateTime date = DateTime.Now.Date; string reportName = "REPORT"; string location = "Department Store"; string description = "computer"; string strAmount = "1000.567"; double amount = Math.Round(1000.567, 2); byte[] receipt = new byte[] { 2, 3, 4, 2 }; int reportId = GetCurrentRowOfReportsTable() + 1; int expenseId = GetCurrentRowOfExpensesTable() + 1; Consultant consultant = new Consultant("41651a9d-3122-4ea2-bfe0-dca38d7248d1"); Supervisor supervisor = new Supervisor("c252413a-1f6c-4086-b35f-1e430f7d7a14"); AccountsStaff accountsStaff = new AccountsStaff("f447b9f3-6733-42aa-b1c5-05a8b4451ca7"); // start transaction using (TransactionScope testTransaction = new TransactionScope()) { consultant.CreateExpense(date, location, description, strAmount, "AUD", receipt); consultant.AddExpenses(reportId); consultant.AddReport(reportName); supervisor.Approve(reportId); accountsStaff.Reject(reportId); ReportsTableAdapter adapter = new ReportsTableAdapter(); Reports.ReportsDataTable reportsTable = new Reports.ReportsDataTable(); adapter.FillById(reportsTable, reportId); foreach (Reports.ReportsRow report in reportsTable) { Assert.AreEqual(reportId, report.Id); Assert.AreEqual(reportName, report.Report_name); Assert.AreEqual(amount, report.Total_amount); Assert.AreEqual("APPROVED", report.Supervisor_approval); Assert.AreEqual("REJECTED", report.Accounts_approval); Assert.AreEqual(consultant.Department, report.Department); Assert.AreEqual(consultant.Username, report.Consultant_id); Assert.AreEqual("NONE", report.Supervisor_id); } testTransaction.Dispose(); // rollback } }