public void LoadSalariedEmployee()
        {
            employee.Schedule       = new BiweeklySchedule();
            employee.Method         = new DirectDepositMethod("1st Bank", "0123456");
            employee.Classification = new SalariedClassification(5432.10);
            database.AddEmployee(employee);

            Employee loadedEmployee = database.GetEmployee(123);

            Assert.AreEqual(123, loadedEmployee.EmpId);
            Assert.AreEqual(employee.Name, loadedEmployee.Name);
            Assert.AreEqual(employee.Address, loadedEmployee.Address);
            PaymentSchedule schedule = loadedEmployee.Schedule;

            Assert.IsTrue(schedule is BiweeklySchedule);

            PaymentMethod method = loadedEmployee.Method;

            Assert.IsTrue(method is DirectDepositMethod);

            DirectDepositMethod ddMethod = method as DirectDepositMethod;

            Assert.AreEqual("1st Bank", ddMethod.Bank);
            Assert.AreEqual("0123456", ddMethod.Account);

            PaymentClassification classification = loadedEmployee.Classification;

            Assert.IsTrue(classification is SalariedClassification);

            SalariedClassification salariedClassification = classification as SalariedClassification;

            Assert.AreEqual(5432.10, salariedClassification.Salary, .01);
        }
Example #2
0
        public void AddSalariedEmployee()
        {
            int empId             = 1;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, "Bob", "Home", 1000.00, database);

            t.Execute();

            Employee e = database.GetEmployee(empId);

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

            PaymentClassification pc = e.Classification;

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

            Assert.AreEqual(1000.00, sc.Salary, .001);
            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is MonthlySchedule);

            PaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
        public void TestSalesReceiptTransaction()
        {
            int empId = 5;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 1000.00, 15);

            t.Execute();

            SalesReceiptTransaction tct = new SalesReceiptTransaction(new DateTime(2005, 7, 31), 200.0, empId);

            tct.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is ComissinedClassification);

            ComissinedClassification hc = pc as ComissinedClassification;
            SalesReceipt             tc = hc.GetSalesReceipt(new DateTime(2005, 7, 31));

            Assert.IsNotNull(tc);
            Assert.AreEqual(200.0, tc.Amount);
        }
        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.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);
        }
Example #5
0
        public void AddServiceChargeTests()
        {
            int empId           = 2;
            var name            = "Bartosz";
            var hourlyRate      = 15.25;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, name, "Home", hourlyRate);

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

            Assert.IsNotNull(e);

            var memberId        = 86;
            var dues            = 88.12;
            UnionAffiliation af = new UnionAffiliation(memberId, dues);

            e.Affiliation = af;
            var date   = new DateTime(2005, 8, 8);
            var charge = 12.95;

            PayrollDatabase.AddUnionMember(memberId, e);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, charge);

            sct.Execute();
            ServiceCharge sc = af.GetServiceCharge(date);

            Assert.IsNotNull(sc);
            Assert.AreEqual(charge, sc.Amount, .001);
        }
        public void TestAddHourlyEmployee()
        {
            int empId           = 1;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bob", "Home", 13.00);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

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

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is HourlyClassification);

            HourlyClassification cc = pc as HourlyClassification;

            Assert.AreEqual(13.00, cc.HourlyRate, .001);

            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule); // They are paid every Friday.

            PaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
        public void TestAddCommissionedEmployee()
        {
            int empId = 1;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bob", "Home", 1000.00, 15);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

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

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is ComissinedClassification);

            ComissinedClassification cc = pc as ComissinedClassification;

            Assert.AreEqual(1000.00, cc.Salary, .001);
            Assert.AreEqual(15, cc.ComissionRate, .001);

            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is BiweeklySchedule); // They are paid every other Friday

            PaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
        public void TestChangeCommissionedTransaction()
        {
            int empId             = 3;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, "Lance", "Home", 2500);

            t.Execute();

            ChangeCommissionedTransaction cht = new ChangeCommissionedTransaction(empId, 3000, 20);

            cht.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsNotNull(pc);
            Assert.IsTrue(pc is ComissinedClassification);

            ComissinedClassification hc = pc as ComissinedClassification;

            Assert.AreEqual(3000, hc.Salary, .001);
            Assert.AreEqual(20, hc.ComissionRate, .001);

            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is BiweeklySchedule);
        }
        public void TestAddHourlyEmployee()
        {
            int               empId      = 3;
            string            name       = "Tomasz";
            double            hourlyRate = 20.0;
            AddHourlyEmployee t          = new AddHourlyEmployee(empId, name, "Home", hourlyRate);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.AreEqual(name, e.Name);

            IPaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is HourlyClassification);

            HourlyClassification hc = pc as HourlyClassification;

            Assert.AreEqual(hourlyRate, hc.HourlyRate, .001);
            IPaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule);

            IPaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
        public void TestAddCommissionedEmployee()
        {
            int    empId              = 2;
            string name               = "Tadeusz";
            double salary             = 1000.0;
            double commissionedRate   = 5.0;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, name, "Home", salary, commissionedRate);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.AreEqual(name, e.Name);

            IPaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is CommissionedClassification);

            CommissionedClassification cc = pc as CommissionedClassification;

            Assert.AreEqual(salary, cc.Salary, .001);
            Assert.AreEqual(commissionedRate, cc.CommissionRate, .001);
            IPaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is BiweeklySchedule);

            IPaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
        public void TestAddSalariedEmployee()
        {
            int    empId          = 1;
            string name           = "Bogdan";
            double salary         = 1000.0;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, name, "Home", salary);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.AreEqual(name, e.Name);

            IPaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is SalariedClassification);

            SalariedClassification sc = pc as SalariedClassification;

            Assert.AreEqual(salary, sc.Salary, .001);
            IPaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is MonthlySchedule);

            IPaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
        public void ShouldStoreEmployeeWithValidValues()
        {
            const int empId = 1;
            var       t     = new AddSalariedEmployee(empId, "Juan", "Address", 1000.00);

            t.Execute();

            var employee = PayrollDatabase.GetEmployee(empId);

            employee.Name.Should().Be("Juan");

            var pc = employee.Classification;

            pc.Should().BeOfType <SalariedClassification>();
            var spc = pc as SalariedClassification;

            spc.Salary.Should().Be(1000.00);

            var ps = employee.Schedule;

            ps.Should().BeOfType <MonthlySchedule>();

            var pm = employee.Method;

            pm.Should().BeOfType <HoldMethod>();
        }
Example #13
0
        public void TestAddCommissionedEmployee()
        {
            int empId = 3;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Jane", "Field", 1000.00, 0.15);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

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

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is CommissionedClassification);
            CommissionedClassification cc = pc as CommissionedClassification;

            Assert.AreEqual(1000.00, cc.Salary, .001);
            Assert.AreEqual(0.15, cc.CommissionRate, .001);
            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is BiweeklySchedule);

            PaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
Example #14
0
        public void TestAddHourlyEmployee()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "John", "Work", 40.00);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

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

            PaymentClassification pc = e.Classification;

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

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

            Assert.IsTrue(ps is WeeklySchedule);

            PaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
Example #15
0
        public void TestSalesReceiptTransaction()
        {
            int empId = 4;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 2500, 3.2);

            t.Execute();

            SalesReceiptTransaction srt = new SalesReceiptTransaction(new DateTime(2005, 7, 31), 20, empId);

            srt.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

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

            SalesReceipt sr = hc.GetSalesReceipt(new DateTime(2005, 7, 31));

            Assert.IsNotNull(sr);
            Assert.AreEqual(20, sr.Amount);
        }
        public void TestChangeHourlyTransaction()
        {
            int empId = 3;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Lance", "Home", 2500, 3.2);

            t.Execute();

            ChangeHourlyTransaction cht = new ChangeHourlyTransaction(empId, 27.52);

            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(27.52, hc.HourlyRate, .001);

            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule);
        }
Example #17
0
        public void TestChangeCommissionedTransaction()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);

            t.Execute();

            ChangeCommissionedTransaction cht = new ChangeCommissionedTransaction(empId, 2500, 3.2);

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

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

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

            Assert.AreEqual(2500, hc.Salary);
            Assert.AreEqual(3.2, hc.CommissionRate);
            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is BiweeklySchedule);
        }
        public void AddMembership()
        {
            int empId           = 8;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);

            t.Execute();

            int memberId = 7743; // Some Union
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, 99.42);

            cmt.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            Affiliation affiliation = e.Affiliation;

            Assert.IsNotNull(affiliation);
            Assert.IsTrue(affiliation is UnionAffiliation);

            UnionAffiliation uf = affiliation as UnionAffiliation;

            Assert.AreEqual(99.42, uf.Dues, .001);

            Employee member = PayrollDatabase.GetUnionMember(memberId);

            Assert.IsNotNull(member);
            Assert.AreEqual(e, member);
        }
Example #19
0
        public void TestAddCommissionEmployee()
        {
            int empId = 1;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bob", "Home", 1000.00, 500.00);

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

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

            PaymentClassification pc = e.Classification;

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

            Assert.AreEqual(1000, sc.Salary);
            Assert.AreEqual(500, sc.CommissionRate);

            PaymentSchedule ps = e.Schedule;

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

            Assert.IsTrue(pm is HoldMethod);
        }
        public void RemoveMembership()
        {
            int empId           = 8;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);

            t.Execute();

            int memberId = 7743; // Some Union
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, 99.42);

            cmt.Execute();

            ChangeUnaffiliatedTransaction cut = new ChangeUnaffiliatedTransaction(empId);

            cut.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            Affiliation affiliation = e.Affiliation;

            Assert.IsNotNull(affiliation);
            Assert.IsTrue(affiliation is NoAffiliation);

            Employee member = PayrollDatabase.GetUnionMember(memberId);

            Assert.IsNull(member);
        }
        public void AddServiceCharge()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            int memberId        = 86; // Maxwell Smart
            UnionAffiliation af = new UnionAffiliation(memberId, 99.42);

            e.Affiliation = af;
            PayrollDatabase.AddUnionMember(memberId, e);

            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, new DateTime(2005, 8, 8), 12.95);

            sct.Execute();

            ServiceCharge sc = af.GetServiceCharges(memberId, new DateTime(2005, 8, 8));

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Charge, .001);
        }
Example #22
0
        public void ChangeUnaffiliatedTransaction()
        {
            var empId = SetupHourlyEmployee();
            // Make sure the employee is union affiliated
            const int memberId = 7743;
            var       cmt      = new ChangeMemberTransaction(empId, memberId, 99.42);

            cmt.Execute();

            var cut = new ChangeUnaffiliatedTransaction(empId);

            cut.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.NotNull(e);

            Affiliation affiliation = e.Affiliation;

            Assert.NotNull(affiliation);

            Assert.IsType <NoAffiliation>(affiliation);
            Employee member = PayrollDatabase.GetUnionMember(memberId);

            Assert.Null(member);
        }
Example #23
0
        public void AddServiceCharge()
        {
            int empId = SetupHourlyEmployee();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.NotNull(e);

            const int memberId = 86; // Maxwell Smart
            var       af       = new UnionAffiliation(memberId, 12.95);

            e.Affiliation = af;
            PayrollDatabase.AddUnionMember(memberId, e);

            var sct = new ServiceChargeTransaction(memberId,
                                                   new DateTime(2005, 8, 8),
                                                   12.95);

            sct.Execute();

            ServiceCharge sc = af.GetServiceCharge(new DateTime(2005, 8, 8));

            Assert.NotNull(sc);
            Assert.Equal(12.95, sc.Amount);
        }
Example #24
0
        public void ChangeUnionMember()
        {
            int       empId    = SetupHourlyEmployee();
            const int memberId = 7743;

            var cmt = new ChangeMemberTransaction(empId, memberId, 99.42);

            cmt.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.NotNull(e);

            Affiliation affiliation = e.Affiliation;

            Assert.NotNull(affiliation);

            var uf = Assert.IsType <UnionAffiliation>(affiliation);

            Assert.Equal(99.42, uf.Dues);

            Employee member = PayrollDatabase.GetUnionMember(memberId);

            Assert.NotNull(member);
            Assert.Same(e, member);
        }
        public void TestTimeCardTransaction()
        {
            int empId           = 5;
            var name            = "Łukasz";
            var hourlyRate      = 15.25;
            var date            = new DateTime(2005, 7, 31);
            var hours           = 8.0;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, name, "Home", hourlyRate);

            t.Execute();

            TimeCardTransaction tct = new TimeCardTransaction(date, hours, empId);

            tct.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            IPaymentClassification pc = e.Classification;

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

            TimeCard tc = hc.GetTimeCard(date);

            Assert.IsNotNull(tc);
            Assert.AreEqual(hours, tc.Hours);
        }
Example #26
0
        public void TestChangeAddressTransaction()
        {
            AddHourlyEmployee t = new AddHourlyEmployee(base.EmpId, base.Name, base.Address, base.HourlyRate);

            t.Execute();
            ChangeAddressTransaction cat = new ChangeAddressTransaction(base.EmpId, base.SecondAddress);

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

            Assert.AreEqual(e.Address, base.SecondAddress);
        }
Example #27
0
        public void ChangeMailMethodTest()
        {
            AddHourlyEmployee he = new AddHourlyEmployee(base.EmpId, base.Name, base.Address, base.HourlyRate);

            he.Execute();
            ChangeMailTransaction cmt = new ChangeMailTransaction(base.EmpId);

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

            Assert.IsTrue(e.Method is MailMethod);
        }
Example #28
0
        public void ChangeAddressTransaction()
        {
            int empId = SetupHourlyEmployee();

            var cat = new ChangeAddressTransaction(empId, "Work");

            cat.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.NotNull(e);
            Assert.Equal("Work", e.Address);
        }
Example #29
0
        public void ChangeNameTransaction()
        {
            int empId = SetupHourlyEmployee();

            var cnt = new ChangeNameTransaction(empId, "Bob");

            cnt.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.NotNull(e);
            Assert.Equal("Bob", e.Name);
        }
        public void Execute()
        {
            var e = PayrollDatabase.GetEmployee(empId);

            if (e != null)
            {
                Change(e);
            }
            else
            {
                throw new InvalidOperationException("Работник не найден.");
            }
        }