예제 #1
0
        public void TestChangeHourlyTransaction()
        {
            var empId = 1;
            var addTx = new AddCommissionedEmployee(empId, "Lance", "Home", 2500, 3.2M);

            addTx.Execute();

            var changeHourlyTx = new ChangeHourlyTransaction(empId, 27.25M);

            changeHourlyTx.Execute();

            var employee = Database.GetEmployee(empId);

            Assert.IsNotNull(employee, "employee not found in database");

            var classification = employee.GetClassification();

            Assert.IsInstanceOfType(classification, typeof(HourlyClassification), "employee does not have hourly classification");

            var hourlyClassification = (HourlyClassification)classification;

            Assert.AreEqual(27.25M, hourlyClassification.HourlyRate);

            var schedule = employee.GetSchedule();

            Assert.IsInstanceOfType(schedule, typeof(WeeklySchedule), "schedule is not weekly");
        }
예제 #2
0
        public void TestChangeHourlyTransaction()
        {
            int empId = 3;
            AddCommissionEmployee t = new AddCommissionEmployee(empId, "Kubing", "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, 0.001);

            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule);
        }
예제 #3
0
        public void GivenNotExistingEmployeeIdToChangeClassifcation_WhenExecute_ThenThrowInvalidOperationException()
        {
            int employeeId = 1000;

            ChangeHourlyTransaction cht = new ChangeHourlyTransaction(employeeId, 19.25);

            Exception ex = Assert.Catch <InvalidOperationException>(() => cht.Execute());

            ex.Message.Should().Contain("No such employee.");
        }
예제 #4
0
        public void ChangeSalariedEmployeeIntoHourlyEmployeeTest()
        {
            AddSalariedEmployee se = new AddSalariedEmployee(base.EmpId, base.Name, base.Address, base.Salary);

            se.Execute();
            ChangeHourlyTransaction cht = new ChangeHourlyTransaction(base.EmpId, base.HourlyRate);

            cht.Execute();
            var e = PayrollDatabase.GetEmployee(base.EmpId);

            Assert.IsTrue(e.Classification is HourlyClassification);
            Assert.IsTrue(e.Schedule is WeeklySchedule);
        }
예제 #5
0
        public void TestChangeHourlyTransaction()
        {
            int employeeId = 12;
            AddEmployTransaction AddHourlyEmployee = new AddSalariedEmployee(employeeId, "Bill", "Home", 1000.0);

            AddHourlyEmployee.Execute();
            Employee e = PayrollRepository.GetEmployee(employeeId);

            e.Classification.Should().BeOfType <SalariedClassification>();
            ChangeHourlyTransaction cht = new ChangeHourlyTransaction(employeeId, 19.25);

            cht.Execute();

            e = PayrollRepository.GetEmployee(employeeId);
            e.Classification.Should().BeOfType <HourlyClassification>();
            HourlyClassification cc = e.Classification as HourlyClassification;

            cc.HourlyRate.Should().Be(19.25);
            e.Schedule.Should().BeOfType <WeeklySchedule>();
        }
예제 #6
0
        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);
        }
예제 #7
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);
        }
예제 #8
0
        public void ChangeHourlyTransaction()
        {
            int empId = SetupCommissionedEmployee();

            var cht = new ChangeHourlyTransaction(empId, 27.52);

            cht.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.NotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.NotNull(pc);
            var hc = Assert.IsType <HourlyClassification>(pc);

            Assert.Equal(27.52, hc.HourlyRate);

            PaymentSchedule ps = e.Schedule;

            Assert.IsType <WeeklySchedule>(ps);
        }
예제 #9
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);
        }
예제 #10
0
        public void TestChangeHourlyTransaction()
        {
            const int empId = 10;
            var       t     = new AddCommissionedEmployee(empId, "Lance", "Home", 2500, 3.2);

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

            cht.Execute();
            var e = PayrollDatabase.GetEmployee(empId);

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

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

            Assert.AreEqual(27.52, hc.HourlyRate, 0.001);
            var ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule);
        }
예제 #11
0
 public void TestChangeHourlyTransaction()
 {
     int empId = 8;
     AddComissionedEmployee t = new AddComissionedEmployee(empId, "Bill", "home", 100, 400);
     t.Execute();
     ChangeHourlyTransaction cht = new ChangeHourlyTransaction(empId, 200);
     cht.Execute();
     Employee e = PayrollDatabase.GetEmployee(empId);
     Assert.IsNotNull(e);
     PaymentClassification pc = e.Classification;
     Assert.IsNotNull(pc);
     Assert.IsTrue(pc is HourlyClassification);
     HourlyClassification hc = pc as HourlyClassification;
     Assert.AreEqual(200, hc.Rate, .001);
     PaymentSchedule ps = e.Schedule;
     Assert.IsTrue(ps is HourlySchedule);
 }