コード例 #1
0
        public void PayrollService_ShouldGetTwoWeeksPayCorrectly_TimeAndHalfCalculatorWithNoOvertime()
        {
            //Arrange
            var date = DateTime.Parse("2018-06-22");

            var timesheetGetRepoMock = new Mock <ITimesheetGetRepository>();

            timesheetGetRepoMock.Setup(x => x.GetTimesheetsForLastTwoWeeks(date))
            .Returns(GetTimesheets());

            var employeeGetRepoMock = new Mock <IEmployeeGetRepository>();

            employeeGetRepoMock.Setup(x => x.Get(1)).Returns(new Employee
            {
                FirstName  = "Test",
                HourlyRate = 100,
                State      = State.TX,
                LastName   = "Test",
                Id         = 1
            });

            var sut = new PayrollService(timesheetGetRepoMock.Object, employeeGetRepoMock.Object);

            //Act
            var paystubs     = sut.GetPaystubs(date);
            var firstPaystub = paystubs.First();

            //Assert
            Assert.That(firstPaystub.TotalOvertimeHoursWorked == 0);
            Assert.That(firstPaystub.TotalOvertimePay == 0);
            Assert.That(firstPaystub.TotalRegularHoursWorked == 80);
            Assert.That(firstPaystub.TotalRegularPay == 8000);
        }