Exemple #1
0
        public void Client2_Process_Employee_Function_Doesnt_Save_When_Contract_date_is_recent()
        {
            //Arrange

            var datacontext = MockRepository.GenerateStub<FakeEmployeeLeaveDataContext>();
            datacontext.EmployeeLeaveStore = new List<EmployeeLeaveRequest>();
            var employee = _testEmployee;
            employee.ContactStartDate = DateTime.Today;
            employee.IsMarried = false;
            datacontext.Employees = new List<Employee>() { employee };
            var businessContext = new Client2EmployeeLeaveBusinessContext(_log, datacontext);

            var sut = MockRepository.GenerateMock<Client2EmployeeLeave>(_log, businessContext);
            
            //Act

            try
            {
                sut.ProcessLeaveRequest(_leaveStartDate, _days, _reason, _employeeId);
                Assert.Fail("Should have failed but did not");
            }
            catch
            {
                //Assert
                Assert.AreEqual(0, datacontext.EmployeeLeaveStore.Count);
            }
        }
Exemple #2
0
        public void Client2_Process_Employee_Function_Saves_Leave_Request_To_Db()
        {
            //Arrange

            var datacontext = MockRepository.GenerateStub<FakeEmployeeLeaveDataContext>();
            datacontext.EmployeeLeaveStore = new List<EmployeeLeaveRequest>();
            var employee = _testEmployee;
            employee.ContactStartDate = DateTime.Today.AddDays(-90);
            employee.IsMarried = true;
            datacontext.Employees = new List<Employee>() { employee };
            
            var businessContext = new Client2EmployeeLeaveBusinessContext(_log,datacontext);
           
            var sut = MockRepository.GenerateMock<Client2EmployeeLeave>(_log, businessContext);
            //Act

            sut.ProcessLeaveRequest(_leaveStartDate,_days,_reason,_employeeId);
            //Assert
            Assert.AreEqual(1, datacontext.EmployeeLeaveStore.Count);
            Assert.AreEqual(_testEmployeeLeaveRequest.EmployeeId, datacontext.EmployeeLeaveStore[0].EmployeeId);
            Assert.AreEqual(_testEmployeeLeaveRequest.LeaveEndDateTime, datacontext.EmployeeLeaveStore[0].LeaveEndDateTime);
            Assert.AreEqual(_testEmployeeLeaveRequest.LeaveStartDateTime, datacontext.EmployeeLeaveStore[0].LeaveStartDateTime);
            Assert.AreEqual(_testEmployeeLeaveRequest.IsApproved, datacontext.EmployeeLeaveStore[0].IsApproved);
        }