public void ShouldValidateOverTimeWithSingleTimePunch()
        {
            //GIVEN
            punches = new List <TimePunch>
            {
                new TimePunch {
                    ClockedIn  = DateTime.Parse("2017-10-11 21:11:00"),
                    ClockedOut = DateTime.Parse("2017-10-12 05:45:00"),
                    Created    = DateTime.Parse("2017-10-11 21:11:38"),
                    HourlyWage = 10,
                    Id         = 4046830,
                    LocationId = 4046830,
                    Modified   = DateTime.Parse("2017-10-12 05:45:49"),
                    UserId     = 517135
                }
            };

            labourSettings = new LabourSettings
            {
                DailyOvertimeMultiplier = 1.5,
                DailyOvertimeThreshold  = 480,
                Overtime = true,
                WeeklyOvertimeMultiplier = 2,
                WeeklyOvertimeThreshold  = 2400
            };

            //WHEN
            var calculator        = new WorkedHourCalculator(new BasicWageCalculator());
            var calculationResult = calculator.CalculateWorkedDay(punches, labourSettings);

            //THEN
            Assert.IsNotNull(calculationResult);
            Assert.AreEqual(8.0d, calculationResult.TotalRegularHours);
            Assert.AreEqual(0.57d, calculationResult.TotalOvertimeHours);
        }
        public void ShouldIdentifyAWorkDateWithMissingClockOut()
        {
            //GIVEN
            punches = new List <TimePunch>
            {
                new TimePunch {
                    ClockedIn  = DateTime.Parse("2017-10-11 21:11:00"),
                    ClockedOut = default(DateTime),
                    Created    = DateTime.Parse("2017-10-11 21:11:38"),
                    HourlyWage = 10,
                    Id         = 4046830,
                    LocationId = 4046830,
                    Modified   = DateTime.Parse("2017-10-12 05:45:49"),
                    UserId     = 517135
                }
            };

            labourSettings = new LabourSettings
            {
                DailyOvertimeMultiplier = 1.5,
                DailyOvertimeThreshold  = 480,
                Overtime = true,
                WeeklyOvertimeMultiplier = 2,
                WeeklyOvertimeThreshold  = 2400
            };

            //WHEN
            var calculator        = new WorkedHourCalculator(new BasicWageCalculator());
            var calculationResult = calculator.CalculateWorkedDay(punches, labourSettings);

            //THEN
            Assert.IsNotNull(calculationResult);
            Assert.IsTrue(calculationResult.Status == Domain.Enum.EWorkHourStatus.MissingClockEntries);
        }
        public void ShouldCalculateWeeklyWageWithoutOvertime()
        {
            decimal employeeHourSalary = 10;

            //GIVEN
            punches = TimePunchesMock.GetThreeWeeksFromEmployee().ToList();

            labourSettings = new LabourSettings
            {
                DailyOvertimeMultiplier = 1.5,
                DailyOvertimeThreshold  = 480,
                Overtime = true,
                WeeklyOvertimeMultiplier = 2,
                WeeklyOvertimeThreshold  = 2400
            };

            //WHEN
            var hourCalculator       = new WorkedHourCalculator(new BasicWageCalculator());
            var calculationResults   = hourCalculator.CalculateWorkedWeek(punches, labourSettings, user).ToArray();
            var wageCalculator       = new BasicWageCalculator();
            var weeklyCalculatedWage = wageCalculator.CalculateWage(calculationResults[0].TotalRegularHours, calculationResults[0].TotalWeekOverTime, employeeHourSalary, (decimal)labourSettings.WeeklyOvertimeMultiplier);
            var dailyCalculatedWage  = wageCalculator.CalculateWage(calculationResults[0].TotalRegularHours, calculationResults[0].TotalDailyOverTime, employeeHourSalary, (decimal)labourSettings.DailyOvertimeMultiplier);

            //THEN

            Assert.IsNotNull(weeklyCalculatedWage);
            Assert.AreEqual(0.0m, weeklyCalculatedWage.OvertimeWage);
            Assert.AreEqual(38.55m, dailyCalculatedWage.OvertimeWage);
            Assert.AreEqual(160m, weeklyCalculatedWage.RegularWage);
        }
        public void ShoudValidateWeeklyTimePunchWithWeekOvertime()
        {
            //GIVEN
            punches = TimePunchesMock.GetThreeWeeksFromEmployee().ToList();

            labourSettings = new LabourSettings
            {
                DailyOvertimeMultiplier = 1.5,
                DailyOvertimeThreshold  = 480,
                Overtime = true,
                WeeklyOvertimeMultiplier = 2,
                WeeklyOvertimeThreshold  = 2400
            };

            //WHEN
            var calculator        = new WorkedHourCalculator(new BasicWageCalculator());
            var calculationResult = calculator.CalculateWorkedWeek(punches, labourSettings, user).ToArray();

            //THEN
            Assert.IsNotNull(calculationResult);
            Assert.AreEqual(2, calculationResult.Count());
            Assert.IsTrue(calculationResult[1].TotalWeekOverTime > 0);
        }