/// <summary>
        /// Creates a valid, transient Employee; typical of something retrieved back from a form submission
        /// </summary>
        public static Employee CreateTransientEmployee() {
            Employee employee = new Employee() {
                FirstName = "Jackie",
                LastName = "Daniels",
                PhoneExtension = 5491
            };

            return employee;
        }
        protected override void LoadTestData() {
            Employee employee = new Employee("Joe", "Smith");
            employeeRepository.SaveOrUpdate(employee);
            FlushSessionAndEvict(employee);

            employee = new Employee("Andrew", "Fuller");
            employeeRepository.SaveOrUpdate(employee);
            FlushSessionAndEvict(employee);
        }
Пример #3
0
        /// <summary>
        /// Transfers the employee entity's property values to the DTO.
        /// Strongly consider Jimmy Bogard's AutoMapper (http://automapper.codeplex.com/) 
        /// for doing this kind of work in a more automated fashion.
        /// </summary>
        public static EmployeeDto Create(Employee employee) {
            if (employee == null)
                return null;

            return new EmployeeDto() {
                Id = employee.Id,
                FirstName = employee.FirstName,
                LastName = employee.LastName
            };
        }
        public void CanCreateDtoWithEntity() {
            Employee employee = new Employee("Steven", "Buchanan");
            EntityIdSetter.SetIdOf(employee, 5);

            EmployeeDto employeeDto = EmployeeDto.Create(employee);

            employeeDto.Id.ShouldEqual(5);
            employeeDto.FirstName.ShouldEqual("Steven");
            employeeDto.LastName.ShouldEqual("Buchanan");
        }