TEST(TimeCardTransactionTest, PayrollTest) { AddHourlyEmployee ahe(5, "Test5", "Shanghai", 100.00); ahe.Execute(); Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(5); EXPECT_TRUE(e->GetName() == "Test5"); EXPECT_TRUE(e->GetAddress() == "Shanghai"); EXPECT_TRUE(e->GetEmpId() == 5); Date date(2010, 10, 10); TimeCardTransaction tct(5, date, 10); tct.Execute(); e = ((DatabaseProxy *)getInstance())->GetEmployee(5); PaymentClassification* pc = e->GetPaymentClassification(); EXPECT_TRUE(pc != 0); HourlyClassification* hc = dynamic_cast<HourlyClassification*>(pc); EXPECT_TRUE(hc != 0); TimeCard timecard(hc->GetTimeCard(date)); EXPECT_TRUE(timecard.GetHours() == 10); }
TEST(AddHourlyEmployeeTest, PayrollTest) { AddHourlyEmployee ht(2, "Test", "Shanghai", 50.00); ht.Execute(); Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(2); EXPECT_TRUE(e->GetName() == "Test"); EXPECT_TRUE(e->GetAddress() == "Shanghai"); EXPECT_TRUE(e->GetEmpId() == 2); PaymentClassification * pc = e->GetPaymentClassification(); HourlyClassification* hc = dynamic_cast<HourlyClassification*>(pc); EXPECT_TRUE(hc != 0); EXPECT_TRUE(hc->GetHourlySalaried() == 50.00); }
TEST(AddSalariedEmployeeTest, PayrollTest) { AddSalariedEmployee st(1, "Bob", "Beijing", 1000.00); st.Execute(); Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(1); EXPECT_TRUE(e->GetName() == "Bob"); EXPECT_TRUE(e->GetAddress() == "Beijing"); EXPECT_TRUE(e->GetEmpId() == 1); PaymentClassification * pc = e->GetPaymentClassification(); SalariedClassification* sc = dynamic_cast<SalariedClassification*>(pc); EXPECT_TRUE(sc != 0); EXPECT_TRUE(sc->GetSalary() == 1000.00); }
TEST(DeleteEmployeeTest, PayrollTest) { AddCommisionEmployee ace(4, "Test4", "Shanghai", 1600.00, 0.3); ace.Execute(); Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(4); EXPECT_TRUE(e->GetName() == "Test4"); EXPECT_TRUE(e->GetAddress() == "Shanghai"); EXPECT_TRUE(e->GetEmpId() == 4); DeleteEmployeeTransaction t(4); t.Execute(); e = ((DatabaseProxy *)getInstance())->GetEmployee(4); EXPECT_TRUE(e == 0); }
TEST(AddCommisionEmployeeTest, PayrollTest) { AddCommisionEmployee ct(3, "Test", "Shanghai", 1500.00, 0.5); ct.Execute(); Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(3); EXPECT_TRUE(e->GetName() == "Test"); EXPECT_TRUE(e->GetAddress() == "Shanghai"); EXPECT_TRUE(e->GetEmpId() == 3); PaymentClassification * pc = e->GetPaymentClassification(); CommisionClassification* hc = dynamic_cast<CommisionClassification*>(pc); EXPECT_TRUE(hc != 0); EXPECT_TRUE(hc->GetSalaried() == 1500.00); EXPECT_TRUE(hc->GetRate() == 0.5); }
void EmployeeListDialog::ShowEmployeeList( std::map<int, Employee*> &itsEmployees ) { QTableWidget *tableWidget = this->ui->tableWidgetEmployeeList; int count = 0; for ( std::map<int, Employee *>::reverse_iterator it = itsEmployees.rbegin(); it != itsEmployees.rend(); ++it ) { Employee *e = it->second; QString strID; tableWidget->setItem(count,0,new QTableWidgetItem(QString::number(e->GetEmpId(), 10))); tableWidget->setItem(count,1,new QTableWidgetItem(e->GetName().c_str())); tableWidget->setItem(count,2,new QTableWidgetItem(e->GetAddress().c_str())); tableWidget->setItem(count,3,new QTableWidgetItem("null")); ++count; } tableWidget->show(); }
TEST(PaydayTransactionForHourlyEmployeeTest, PayrollTest) { ((DatabaseProxy *)getInstance())->ClearEmployees(); int empid = 102; AddHourlyEmployee ahe(empid, "name02", "Shanghai", 20.00); ahe.Execute(); Employee *e = ((DatabaseProxy *)getInstance())->GetEmployee(empid); EXPECT_TRUE(e->GetName() == "name02"); EXPECT_TRUE(e->GetAddress() == "Shanghai"); EXPECT_TRUE(e->GetEmpId() == empid); Date date(2012, 2, 5); TimeCardTransaction tct(empid, date, 10); tct.Execute(); e = ((DatabaseProxy *)getInstance())->GetEmployee(empid); PaymentClassification* pc = e->GetPaymentClassification(); EXPECT_TRUE(pc != 0); HourlyClassification* hc = dynamic_cast<HourlyClassification*>(pc); EXPECT_TRUE(hc != 0); TimeCard timecard(hc->GetTimeCard(date)); EXPECT_TRUE(timecard.GetHours() == 10); Date paydate(2011, 2, 7); PaydayTransaction pt(paydate); pt.Execute(); PayCheck *check = pt.GetPayCheck(empid); EXPECT_TRUE(check != NULL); EXPECT_TRUE(check->GetName() == "name02"); EXPECT_EQ(check->GetGrossPay(), 200.00); EXPECT_EQ(check->GetDeductions(), 0.0); EXPECT_EQ(check->GetNetPay(), 200.00); }