コード例 #1
0
        public void ChangeUnionMember()
        {
            int employeeId           = 18;
            AddEmployTransaction aet = new AddHourlyEmployee(employeeId, "Bill", "home", 19.1);

            aet.Execute();

            int memberId = 8591;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(employeeId, memberId, 99.42);

            cmt.Execute();

            Employee e = PayrollRepository.GetEmployee(employeeId);

            e.Should().NotBeNull();
            e.Affiliation.Should().NotBeNull();
            e.Affiliation.Should().BeOfType <UnionAffiliation>();

            UnionAffiliation uf = e.Affiliation as UnionAffiliation;

            uf.Dues.Should().Be(99.42);
            Employee member = PayrollRepository.GetUnionMember(memberId);

            member.Should().NotBeNull();
            member.Should().Be(e);
        }
コード例 #2
0
        public void ChangeUnaffiliatedTransaction()
        {
            int employeeId           = 19;
            AddEmployTransaction aet = new AddHourlyEmployee(employeeId, "Bill", "home", 19.1);

            aet.Execute();
            int memberId = 8592;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(employeeId, memberId, 99.42);

            cmt.Execute();
            Employee um = PayrollRepository.GetUnionMember(memberId);

            um.Should().NotBeNull();
            ChangeUnaffiliatedTransaction cut = new ChangeUnaffiliatedTransaction(employeeId);

            cut.Execute();

            Employee e = PayrollRepository.GetEmployee(employeeId);

            e.Should().NotBeNull();
            e.Affiliation.Should().NotBeNull();
            e.Affiliation.Should().BeOfType <NoAffiliaction>();

            Employee member = PayrollRepository.GetUnionMember(memberId);

            member.Should().BeNull();
        }
コード例 #3
0
        public void TestAddSalesReceiptTransaction()
        {
            #region Arrange
            int employeeId            = 5;
            AddCommissionedEmployee t = new AddCommissionedEmployee(employeeId, "user", "home", 1000, 97.5);
            t.Execute();

            DateTime workingDate        = new DateTime(2019, 4, 21);
            SalesReceiptTransaction srt = new SalesReceiptTransaction(
                employeeId, workingDate, 200
                );
            #endregion

            #region Action
            srt.Execute();
            #endregion

            #region Assert
            Employee e = PayrollRepository.GetEmployee(employeeId);
            e.Should().NotBeNull();

            e.Classification.Should().BeOfType <CommissionedClassification>();
            CommissionedClassification cc = e.Classification as CommissionedClassification;

            SalesReceipt sr = cc.GetSalesReceipt(workingDate);
            sr.Should().NotBeNull();
            sr.Amount.Should().Be(200);
            #endregion
        }
コード例 #4
0
        public void TestAddTimeCard()
        {
            #region Arrange
            int employeeId      = 7;
            AddHourlyEmployee t = new AddHourlyEmployee(employeeId, "user", "home", 97.5);
            t.Execute();

            DateTime            workingDay = new DateTime(2019, 4, 21);
            TimeCardTransaction tct        = new TimeCardTransaction(
                employeeId, workingDay, 8.0
                );
            #endregion

            #region Action
            tct.Execute();
            #endregion

            #region Assert
            Employee e = PayrollRepository.GetEmployee(employeeId);
            e.Should().NotBeNull();

            e.Classification.Should().BeOfType <HourlyClassification>();
            HourlyClassification hc = e.Classification as HourlyClassification;

            TimeCard tc = hc.GetTimeCard(workingDay);
            tc.Should().NotBeNull();
            tc.Hours.Should().Be(8.0);
            #endregion
        }
コード例 #5
0
        public void TestAddServiceCharge()
        {
            #region Arrange
            int employeeId          = 9;
            AddSalariedEmployee asd = new AddSalariedEmployee(employeeId, "user", "home", 1000.0);
            asd.Execute();
            Employee e = PayrollRepository.GetEmployee(employeeId);
            e.Should().NotBeNull();

            UnionAffiliation af = new UnionAffiliation();
            e.Affiliation = af;
            int memberId = 886;
            PayrollRepository.AddUnionMember(memberId, e);

            ServiceChargeTransaction sct = new ServiceChargeTransaction(
                memberId, new DateTime(2019, 10, 10), 10.0);
            #endregion

            #region Action
            sct.Execute();
            #endregion

            #region Assert
            ServiceCharge sc = af.GetServiceCharge(new DateTime(2019, 10, 10));
            sc.Should().NotBeNull();
            sc.Date.Should().Be(new DateTime(2019, 10, 10));
            sc.Amount.Should().Be(10.0);
            #endregion
        }
コード例 #6
0
 public HrUnitOfWork(IContextFactory <DbContext> contextFactory) // , int companyId, string culture
     : base(contextFactory)
 {
     // Initialize
     CompanyRepository          = new CompanyRepository(Context); // , companyId, culture
     PagesRepository            = new PagesRepository(Context);
     MenuRepository             = new MenuRepository(Context);
     PageEditorRepository       = new PageEditorRepository(Context);
     LookUpRepository           = new LookUpRepoitory(Context);
     CompanyStructureRepository = new CompanyStructureRepository(Context);
     JobRepository           = new JobRepository(Context);
     PeopleRepository        = new PeopleRepository(Context);
     PositionRepository      = new PositionRepository(Context);
     BudgetRepository        = new BudgetRepository(Context);
     QualificationRepository = new QualificationRepository(Context);
     LeaveRepository         = new LeaveRepository(Context);
     EmployeeRepository      = new EmployeeRepository(Context);
     CustodyRepository       = new CustodyRepository(Context);
     TrainingRepository      = new TrainingRepository(Context);
     BenefitsRepository      = new BenefitsRepository(Context);
     AudiTrialRepository     = new AudiTrialRepository(Context);
     TerminationRepository   = new TerminationRepository(Context);
     DisciplineRepository    = new DisciplineRepository(Context);
     CheckListRepository     = new CheckListRepository(Context);
     ComplaintRepository     = new ComplaintRepository(Context);
     MessageRepository       = new MessageRepository(Context);
     MedicalRepository       = new MedicalRepository(Context);
     HrLettersRepository     = new HRLettersRepository(Context);
     PayrollRepository       = new PayrollRepository(Context);
     SalaryDesignRepository  = new SalaryDesignRepository(Context);
     NotificationRepository  = new NotificationRepository(Context);
     MissionRepository       = new MissionRepository(Context);
     MeetingRepository       = new MeetingRepository(Context);
 }
コード例 #7
0
        public void TestAddCommissionedEmployee()
        {
            #region Arrange
            int    empId              = 3;
            string userName           = "******";
            string address            = "Xindian";
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, userName, address, 500.0, 97.5);
            #endregion

            #region Action
            t.Execute();
            #endregion

            #region Assert
            Employee e = PayrollRepository.GetEmployee(empId);
            e.Name.Should().Be(userName);
            e.Address.Should().Be(address);

            PaymentClassification pc = e.Classification;
            pc.Should().BeOfType <CommissionedClassification>();
            CommissionedClassification cc = pc as CommissionedClassification;
            cc.Salary.Should().Be(500.0);
            cc.CommissionedRate.Should().Be(97.5);

            PaymentSchedule ps = e.Schedule;
            ps.Should().BeOfType <BiweeklySchedule>();

            PaymentMethod pm = e.Method;
            pm.Should().BeOfType <HoldMethod>();
            #endregion
        }
コード例 #8
0
        public void TestAddHourlyEmployee()
        {
            #region Arrange
            int               empId    = 2;
            string            userName = "******";
            string            address  = "Xindian";
            AddHourlyEmployee t        = new AddHourlyEmployee(empId, userName, address, 97.5);
            #endregion

            #region Action
            t.Execute();
            #endregion

            #region Assert
            Employee e = PayrollRepository.GetEmployee(empId);
            e.Name.Should().Be(userName);
            e.Address.Should().Be(address);

            PaymentClassification pc = e.Classification;
            pc.Should().BeOfType <HourlyClassification>();
            HourlyClassification hc = pc as HourlyClassification;
            hc.HourlyRate.Should().Be(97.5);

            PaymentSchedule ps = e.Schedule;
            ps.Should().BeOfType <WeeklySchedule>();

            PaymentMethod pm = e.Method;
            pm.Should().BeOfType <HoldMethod>();
            #endregion
        }
コード例 #9
0
        public void TestAddSalariedEmployee()
        {
            #region Arrange
            int    empId          = 1;
            string userName       = "******";
            AddSalariedEmployee t = new AddSalariedEmployee(empId, userName, "Xindian", 1000.0);
            #endregion

            #region Action
            t.Execute();
            #endregion

            #region Assert
            Employee e = PayrollRepository.GetEmployee(empId);
            e.Name.Should().Be(userName);

            PaymentClassification pc = e.Classification;
            pc.Should().BeOfType <SalariedClassification>();
            SalariedClassification sc = pc as SalariedClassification;
            sc.Salary.Should().Be(1000.00);

            PaymentSchedule ps = e.Schedule;
            ps.Should().BeOfType <MonthlySchedule>();

            PaymentMethod pm = e.Method;
            pm.Should().BeOfType <HoldMethod>();
            #endregion
        }
コード例 #10
0
        public void Execute()
        {
            _employee.Classification = CreatePaymentClassification();
            _employee.Schedule       = CreatePaymentSchedule();
            _employee.Method         = new HoldMethod();
            _employee.Affiliation    = new NoAffiliaction();

            PayrollRepository.AddEmpoyee(_employee.Id, _employee);
        }
コード例 #11
0
        public override void RecordMemberShip(Employee employee)
        {
            UnionAffiliation ua = employee.Affiliation as UnionAffiliation;

            if (ua != null)
            {
                int memberId = ua.MemberId;
                PayrollRepository.RemoveUnionMember(memberId);
            }
        }
コード例 #12
0
        public void Execute()
        {
            Employee e = PayrollRepository.GetEmployee(_employeeId);

            if (e != null)
            {
                Change(e);
            }
            else
            {
                throw new InvalidOperationException("No such employee.");
            }
        }
コード例 #13
0
        public void UpdateMultipleEmployeesWithThreadingAndSynchronisation()
        {
            //Arrange
            PayrollRepository payrollRepository = new PayrollRepository();
            List <string>     employeeNames     = new List <string>();

            //Act
            employeeNames.Add("Mukhesh");
            employeeNames.Add("Riya");
            bool actual   = payrollRepository.UpdateEmployeesWithThreadsAndSynchronization(employeeNames);
            bool expected = true;

            ///Assert
            Assert.AreEqual(expected, actual);
        }
コード例 #14
0
        public void TestChangeNameTransaction()
        {
            int employeeId         = 10;
            AddEmployTransaction t = new AddHourlyEmployee(employeeId, "Bill", "Home", 15.25);

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

            e.Name.Should().Be("Bill");
            ChangeNameTransaction cnt = new ChangeNameTransaction(employeeId, "Bob");

            cnt.Execute();

            e = PayrollRepository.GetEmployee(employeeId);
            e.Name.Should().Be("Bob");
        }
コード例 #15
0
        public void TestChangeAddressTransaction()
        {
            int employeeId         = 11;
            AddEmployTransaction t = new AddHourlyEmployee(employeeId, "Bill", "Home", 15.25);

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

            e.Address.Should().Be("Home");
            ChangeAddressTransaction cat = new ChangeAddressTransaction(employeeId, "Company");

            cat.Execute();

            e = PayrollRepository.GetEmployee(employeeId);
            e.Address.Should().Be("Company");
        }
コード例 #16
0
        public void Execute()
        {
            ArrayList employeeIds = PayrollRepository.GetAllEmployeeIds();

            foreach (int eachId in employeeIds)
            {
                Employee e = PayrollRepository.GetEmployee(eachId);
                if (e.IsPayday(_payDate))
                {
                    PayCheck pc = new PayCheck(_payDate);
                    _payChecks[eachId] = pc;
                    e.Payday(pc);
                    pc.PayDate = _payDate;
                }
            }
        }
コード例 #17
0
        public void Execute()
        {
            Employee e = PayrollRepository.GetUnionMember(_memberId);
            bool     isExistingMember = e != null;

            if (isExistingMember)
            {
                UnionAffiliation ua = e.Affiliation as UnionAffiliation;
                ServiceCharge    sc = new ServiceCharge(_date, _amount);
                ua.AddServiceCharge(sc);
            }
            else
            {
                throw new InvalidOperationException("No such union member.");
            }
        }
コード例 #18
0
        public void TestChangeHoldMethodTransaction()
        {
            int employeeId           = 17;
            AddEmployTransaction aet = new AddSalariedEmployee(employeeId, "Bob", "Home", 1000.0);

            aet.Execute();
            Employee e = PayrollRepository.GetEmployee(employeeId);
            ChangeDirectMethodTransaction cdmt = new ChangeDirectMethodTransaction(employeeId, "ctbc", "1234");

            cdmt.Execute();
            e.Method.Should().BeOfType <DirectMethod>();
            ChangeHoldMethodTransaction chmt = new ChangeHoldMethodTransaction(employeeId);

            chmt.Execute();

            e = PayrollRepository.GetEmployee(employeeId);
            e.Method.Should().BeOfType <HoldMethod>();
        }
コード例 #19
0
        public void TestChangeMailMethodTransaction()
        {
            int employeeId           = 15;
            AddEmployTransaction aet = new AddSalariedEmployee(employeeId, "Bob", "Home", 1000.0);

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

            e.Method.Should().BeOfType <HoldMethod>();
            ChangeMailMethodTransation cmmt = new ChangeMailMethodTransation(employeeId, "home");

            cmmt.Execute();

            e = PayrollRepository.GetEmployee(employeeId);
            e.Method.Should().BeOfType <MailMethod>();
            MailMethod mm = e.Method as MailMethod;

            mm.Address.Should().Be("home");
        }
コード例 #20
0
        public async Task CanGetDatesPaid()
        {
            foreach (var testAccount in TestAccounts.TyLinAccounts.Accounts)
            {
                var employer = EmployerCache.Employers.FirstOrDefault(e =>
                                                                      e.Id == testAccount.EmployerId);

                var repository = new PayrollRepository();
                repository.Initialize(employer.ConnectionString);

                var dispatcher = new PayrollDispatcher(repository);
                var controller = new PayrollController(dispatcher);

                var result = await controller.GetDatesPaidAsync(employer, testAccount.CchId);

                Assert.IsNotNull(result);
                //Assert.IsNotNull(result.Content);
            }
        }
コード例 #21
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>();
        }
コード例 #22
0
        public void TestChangeSalariedTransaction()
        {
            int employeeId           = 14;
            AddEmployTransaction ahe = new AddHourlyEmployee(employeeId, "Bill", "Home", 95.0);

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

            e.Classification.Should().BeOfType <HourlyClassification>();
            ChangeSalariedTransation cst = new ChangeSalariedTransation(employeeId, 1000.0);

            cst.Execute();

            e = PayrollRepository.GetEmployee(employeeId);
            e.Classification.Should().BeOfType <SalariedClassification>();
            SalariedClassification sc = e.Classification as SalariedClassification;

            sc.Salary.Should().Be(1000.0);
            e.Schedule.Should().BeOfType <MonthlySchedule>();
        }
コード例 #23
0
        public void TestDeleteEmployee()
        {
            #region Arrange
            int employeeId        = 4;
            AddSalariedEmployee t = new AddSalariedEmployee(employeeId, "user", "home", 1000.0);
            t.Execute();
            Employee e = PayrollRepository.GetEmployee(employeeId);
            e.Should().NotBeNull();

            DeleteEmployeeTransaction dt = new DeleteEmployeeTransaction(employeeId);
            #endregion

            #region Action
            dt.Execute();
            #endregion

            #region Assert
            e = PayrollRepository.GetEmployee(employeeId);
            e.Should().BeNull();
            #endregion
        }
コード例 #24
0
        public void TestChangeCommissionedTransaction()
        {
            int employeeId = 13;
            AddEmployTransaction AddHourlyEmployee = new AddSalariedEmployee(employeeId, "Bill", "Home", 1000.0);

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

            e.Classification.Should().BeOfType <SalariedClassification>();
            ChangeCommissionedTransaction cct = new ChangeCommissionedTransaction(employeeId, 800.0, 19.25);

            cct.Execute();

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

            cc.Salary.Should().Be(800.0);
            cc.CommissionedRate.Should().Be(19.25);
            e.Schedule.Should().BeOfType <BiweeklySchedule>();
        }
コード例 #25
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.");
            }
        }
コード例 #26
0
        public async Task CanGetPaycheck()
        {
            foreach (var testAccount in TestAccounts.TyLinAccounts.Accounts)
            {
                var employer = EmployerCache.Employers.FirstOrDefault(e =>
                                                                      e.Id == testAccount.EmployerId);

                var repository = new PayrollRepository();
                repository.Initialize(employer.ConnectionString);

                var dispatcher = new PayrollDispatcher(repository);
                var controller = new PayrollController(dispatcher);

                controller.ControllerContext.Request = new System.Net.Http.HttpRequestMessage();
                controller.ControllerContext.Request.CCHID(testAccount.CchId);

                var result = await controller.GetPaycheckAsync(employer, testAccount.PaycheckDocumentId);

                Assert.IsNotNull(result);
                //Assert.IsNotNull(result.Content);
            }
        }
コード例 #27
0
        public void AddMultipleEmployeesWithThreading()
        {
            //Arrange
            PayrollRepository      payrollRepository = new PayrollRepository();
            List <EmployeeDetails> employeelist      = new List <EmployeeDetails>();

            //Act
            employeelist.Add(new EmployeeDetails
            {
                empName     = "Manish",
                gender      = 'M',
                phoneNumber = "2345167898",
                startDate   = new System.DateTime(2019, 08, 24),
                payrollId   = 6,
                BasePay     = 80000,
                Deductions  = 1000,
                IncomeTax   = 4000,
                TaxablePay  = 5000
            });
            employeelist.Add(new EmployeeDetails
            {
                empName     = "Smriti",
                gender      = 'F',
                phoneNumber = "2345167437",
                startDate   = new System.DateTime(2019, 11, 09),
                payrollId   = 7,
                BasePay     = 40000,
                Deductions  = 1500,
                IncomeTax   = 2000,
                TaxablePay  = 4000
            });

            bool actual   = payrollRepository.AddMultipleEmployeeWithThreads(employeelist);
            bool expected = true;

            ///Assert
            Assert.AreEqual(expected, actual);
        }
コード例 #28
0
        public void AddMultipleEmployees()
        {
            //Arrange
            PayrollRepository      payrollRepository = new PayrollRepository();
            List <EmployeeDetails> employeelist      = new List <EmployeeDetails>();

            //Act
            employeelist.Add(new EmployeeDetails
            {
                empName     = "Vijay",
                gender      = 'M',
                phoneNumber = "2345167868",
                startDate   = new System.DateTime(2019, 08, 24),
                payrollId   = 4,
                BasePay     = 36000,
                Deductions  = 1000,
                IncomeTax   = 2000,
                TaxablePay  = 4000
            });
            employeelist.Add(new EmployeeDetails
            {
                empName     = "Sankar",
                gender      = 'M',
                phoneNumber = "2345167456",
                startDate   = new System.DateTime(2019, 11, 09),
                payrollId   = 5,
                BasePay     = 40000,
                Deductions  = 1500,
                IncomeTax   = 2000,
                TaxablePay  = 4000
            });

            bool actual   = payrollRepository.AddMultipleEmployee(employeelist);
            bool expected = true;

            ///Assert
            Assert.AreEqual(expected, actual);
        }
コード例 #29
0
        public void Execute()
        {
            Employee e = PayrollRepository.GetEmployee(_employeeId);
            bool     isValidEmployee = e != null;

            if (isValidEmployee)
            {
                CommissionedClassification cc = e.Classification as CommissionedClassification;
                bool isCommenssionedEmployee  = cc != null;
                if (isCommenssionedEmployee)
                {
                    cc.AddSalesReceipt(_employeeId, _workingDate, _amount);
                }
                else
                {
                    throw new InvalidOperationException("non-commenssioned employee");
                }
            }
            else
            {
                throw new InvalidOperationException("No such employee.");
            }
        }
コード例 #30
0
 public void SetUp()
 {
     payrollRepository = PayrollRepository.GetInstance();
 }