Esempio n. 1
0
        public void TimeCardTransaction()
        {
            int empid           = 6;
            AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bob", "Home", 23.41);

            t.Execute();
            TimeCardTransaction tct = new TimeCardTransaction(new DateTime(2015, 10, 31), 8.0, empid);

            tct.Execute();
            Employee e = PayrollDatabase.GetEmployee_Static(empid);

            Assert.IsNotNull(e);
            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;
            TimeCard             tc = hc.GetTimeCard(new DateTime(2015, 10, 31));

            Assert.IsNotNull(tc);
            Assert.AreEqual(8.0, tc.Hours);
        }
Esempio n. 2
0
 public void Execute()
 {
     Employee employee = PayRollDatabase.GetEmloyee(_empId);
     if (employee != null)
     {
         HourlyClassification hc = employee.Classification as HourlyClassification;
         if (hc != null)
         {
             hc.AddTimeCard(new TimeCard(_date, _hourse)));
         }
         else
         {
             throw new InvalidOperationException("Попытка добавить карточку табельного учёта" +
                 "для работника не на почасовой оплате");
         }
     }
     else
     {
         throw new InvalidOperationException("Работник не найден");
     }
 }
        public void LoadHourlyEmployeeTwoTimeCards()
        {
            employee.Schedule       = new WeeklySchedule();
            employee.Method         = new DirectDepositMethod("1st Bank", "0123456");
            employee.Classification = new HourlyClassification(180.50);
            database.AddEmployee(employee);

            DateTime            payDate         = new DateTime(2001, 11, 9); //Friday
            DateTime            previousPayDate = payDate.AddDays(-7);
            TimeCardTransaction tct1            = new TimeCardTransaction(payDate, 9.0, 123, database);

            tct1.Execute();

            TimeCardTransaction tct2 = new TimeCardTransaction(previousPayDate, 5.0, 123, database);

            tct2.Execute();

            Employee loadedEmployee = database.GetEmployee(123);
            PaymentClassification classification = loadedEmployee.Classification;

            Assert.IsTrue(classification is HourlyClassification);

            HourlyClassification hourlyClassification = classification as HourlyClassification;

            Assert.AreEqual(180.50, hourlyClassification.HourlyRate, .01);

            var timeCards = hourlyClassification.TimeCards;

            Assert.AreEqual(2, timeCards.Count);

            var tc1 = timeCards[payDate] as TimeCard;

            Assert.IsNotNull(tc1);
            Assert.AreEqual(9.0, tc1.Hours);

            var tc2 = timeCards[previousPayDate] as TimeCard;

            Assert.IsNotNull(tc2);
            Assert.AreEqual(5.0, tc2.Hours);
        }
Esempio n. 4
0
        public void TestAddHourlyEmployee()
        {
            int empId           = 1;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Йорик", "Гочина 23", 2000.00);

            t.Execute();
            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.AreEqual("Йорик", e.name);
            PaymentClassification pc = e.classification;

            Assert.IsTrue(pc is HourlyClassification);
            HourlyClassification sc = pc as HourlyClassification;

            Assert.AreEqual(2000.00, sc.HourlyRate, .001);
            PaymentSchedule ps = e.schedule;

            Assert.IsTrue(ps is WeeklySchedule);
            PaymentMethod pm = e.method;

            Assert.IsTrue(pm is HoldMethod);
        }
Esempio n. 5
0
        public void AddHourlyEmployee()
        {
            int empid           = 3;
            AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bill", "Home", 265);

            t.Execute();
            Employee e = PayrollDatabase.GetEmployee_Static(empid);

            Assert.AreEqual("Bill", e.Name);
            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is HourlyClassification);
            HourlyClassification sc = pc as HourlyClassification;

            Assert.AreEqual(265, sc.Hourly, .001);
            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule);
            PaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
        public void ExecuteTest()
        {
            int    empId      = 21;
            double hourlyRate = 2.3;

            AddEmployeeTransaction addSalEmp = new AddSalariedEmployee(empId, "kara", "samubola", 3000, database);

            addSalEmp.Execute();

            ChangeClassificationTranscation changeHourlyTrans = new ChangeHourlyTransaction(empId, hourlyRate, database);

            changeHourlyTrans.Execute();
            Employee emp = database.GetEmployee(empId);

            Assert.IsNotNull(emp);
            Assert.IsTrue(emp.Classification is HourlyClassification);

            HourlyClassification hc = emp.Classification as HourlyClassification;

            Assert.IsNotNull(hc);
            Assert.AreEqual(hc.HourlyRate, hourlyRate);
        }
Esempio n. 7
0
        public async Task TimeCardTransaction()
        {
            int empId           = 3;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);
            await t.ExecuteAsync();

            TimeCardTransaction tct = new TimeCardTransaction(new DateTime(2005, 7, 31), 8.0, empId);
            await tct.ExecuteAsync();

            Employee e = await PayrollDatabase.GetEmployeeAsync(empId);

            Assert.NotNull(e);

            Classification.PaymentClassification pc = e.Classification;
            Assert.True(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;

            TimeCard tc = hc.GetTimeCard(new DateTime(2005, 7, 31));

            Assert.NotNull(tc);
            Assert.Equal(8.0, tc.Hours);
        }
Esempio n. 8
0
        public async Task ChangeHourlyTransaction()
        {
            int empId = 6;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Lance", "Home", 2500, 3.2);
            await t.ExecuteAsync();

            ChangeHourlyTransaction cht = new ChangeHourlyTransaction(empId, 27.52);
            await cht.ExecuteAsync();

            Employee e = await PayrollDatabase.GetEmployeeAsync(empId);

            Assert.NotNull(e);
            Classification.PaymentClassification pc = e.Classification;
            Assert.NotNull(pc);
            Assert.True(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;

            Assert.Equal(27.52, hc.HourlyRate);
            IPaymentSchedule ps = e.Schedule;

            Assert.True(ps is WeeklySchedule);
        }
        public void AddHourlyEmployee()
        {
            int     emplid           = 2;
            string  address          = "2nd street";
            string  fullName         = "Kyle Kornetzke";
            decimal hourlyRate       = 10.0m;
            AddEmployeeTransaction t = new AddHourlyEmployee(emplid, address, fullName, hourlyRate);

            t.Execute();

            Employee e = Database.GetEmployee(emplid);

            Assert.AreEqual(emplid, e.Emplid);
            Assert.AreEqual(address, e.Address);
            Assert.AreEqual(fullName, e.FullName);

            CheckEmployeePaymentTypes(typeof(HourlyClassification), typeof(HoldMethod), typeof(WeeklySchedule), e);

            HourlyClassification h = e.paymentClassification as HourlyClassification;

            Assert.AreEqual(hourlyRate, h.HourlyRate);
        }
Esempio n. 10
0
        public void Execute()
        {
            Employee e = PayrollRepository.GetEmployee(_employeeId);

            if (e != null)
            {
                HourlyClassification hc = e.Classification as HourlyClassification;
                bool isHourlyEmployee   = hc != null;
                if (isHourlyEmployee)
                {
                    hc.AddTimeCard(_employeeId, _workingDate, _workingHours);
                }
                else
                {
                    throw new InvalidOperationException("non-hourly employee");
                }
            }
            else
            {
                throw new InvalidOperationException("No such employee.");
            }
        }
Esempio n. 11
0
        public void ExecuteTest()
        {
            AddEmployeeTransaction addEmp = new AddHourlyEmployee(2, "Cala", "Selee Street", 0.8, database);

            addEmp.Execute();
            Employee emp = database.GetEmployee(2);

            Assert.IsNotNull(emp);

            PaymentClassification classification = emp.Classification;
            PaymentMethod         method         = emp.Method;
            PaymentSchedule       schedule       = emp.Schedule;

            Assert.AreEqual("Cala", emp.Name);
            Assert.IsTrue(classification is HourlyClassification);
            Assert.IsTrue(method is HoldMethod);
            Assert.IsTrue(schedule is WeeklySchedule);

            HourlyClassification hourlyClassifiction = classification as HourlyClassification;

            Assert.AreEqual(0.8, hourlyClassifiction.HourlyRate, 0.0001);
        }
Esempio n. 12
0
        public void TestTimeCardTransaction()
        {
            int empId = 5;

            app.ExexcuteTransaction("addHourlyEmployee", RequestFactory.rf.MakeHourlyEmployeeRequest(empId, "Bob", "Home", 50));

            app.ExexcuteTransaction("addTimeCard", RequestFactory.rf.MakeTimeCardRequest(new DateTime(2005, 7, 31), 8.0, empId));

            Employee e = PayrollDb.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;

            TimeCard tc = hc.GetTimeCard(new DateTime(2005, 7, 31));

            Assert.IsNotNull(tc);
            Assert.AreEqual(8.0, tc.Hours);
        }
Esempio n. 13
0
        public void ChangeHourlyTransaction()
        {
            int empid = 11;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empid, "Bill", "Home", 23.41, 3.2);

            t.Execute();
            ChangeHourlyTransaction cht = new ChangeHourlyTransaction(empid, 19.84);

            cht.Execute();
            Employee e = PayrollDatabase.GetEmployee_Static(empid);

            Assert.IsNotNull(e);
            PaymentClassification pc = e.Classification;

            Assert.IsNotNull(pc);
            Assert.IsTrue(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;

            Assert.AreEqual(19.84, hc.Hourly, .001);
            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule);
        }
        public void TestTimeCardTransaction()
        {
            int empId           = 5;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);

            t.Execute();
            TimeCardTransaction() tct = new TimeCardTransaction(new DateTime(2005, 7, 31), 8.0, empId);
            tct.Execute();

            Employee e = PayrollDatabase.GetEmloyee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;

            TestTimeCardTransaction tc = hc.GetTimeCard(new DateTime(2005, 7, 31));

            Assert.IsNotNull(tc);
            Assert.AreEqual(8.0, tc.Hours);
        }
Esempio n. 15
0
        public void TestChangeHourlyTransactionTest()
        {
            int empId = 3;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Lance", "Home", 2500, 3.2, database);

            t.Execute();
            ChangeHourlyTransaction cht = new ChangeHourlyTransaction(empId, 27.52, database);

            cht.Execute();
            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);
            PaymentClassification pc = e.Classification;

            Assert.IsNotNull(pc);
            Assert.IsTrue(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;

            Assert.AreEqual(27.52, hc.HourlyRate, .001);
            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule);
        }
Esempio n. 16
0
        public void TestAddHourlyEmployee()
        {
            int empId           = 1;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bob", "Home", 5.00);

            t.Execute();
            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.AreEqual("Bob", e.Name);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is HourlyClassification);
            HourlyClassification sc = pc as HourlyClassification;

            Assert.AreEqual(5.00, sc.HourlyRate);

            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule);
            PaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }