public void Should_return_two()
        {
            var employeeRepository = MockRepository.GenerateStub<IGenericRepository<Employee>>();

            var mockEmployees = new List<Employee>
                                    {
                                        new Employee
                                            {
                                                ID = 2,
                                                EmployeeCode = 456,
                                                Name = "Jill",
                                                StartDate = Convert.ToDateTime("18/Dec/2011")
                                            },
                                        new Employee
                                            {
                                                ID = 3,
                                                EmployeeCode = 789,
                                                Name = "Sue",
                                                StartDate = Convert.ToDateTime("24/Dec/2011")
                                            }
                                    };

            employeeRepository.Stub(x => x.Get())
                              .IgnoreArguments()
                              .Return(mockEmployees);

            IEmployeeManagement employeeManagement = new EmployeeManagement(employeeRepository);

            List<EmployeeExternal> employeeExternalList = employeeManagement.RetrieveAfterStartDate(Convert.ToDateTime("18/Dec/2011"));

            Assert.AreEqual(2, employeeExternalList.Count);
        }
Esempio n. 2
0
        public void Existing_should_be_deleted()
        {
            var employeeRepository = MockRepository.GenerateStub<IGenericRepository<Employee>>();

            IEmployeeManagement employeeManagement = new EmployeeManagement(employeeRepository);

            employeeManagement.DeleteEmployee(6);
        }
        public void Should_return_one()
        {
            var employeeRepository = MockRepository.GenerateStub<IGenericRepository<Employee>>();

            var mockEmployees = new List<Employee> {new Employee {ID = 1, EmployeeCode = 123}};

            employeeRepository.Stub(x => x.Get())
                              .IgnoreArguments()
                              .Return(mockEmployees);

            IEmployeeManagement employeeManagement = new EmployeeManagement(employeeRepository);

            EmployeeExternal employeeExternal = employeeManagement.RetrieveByEmployeeCode(123);

            Assert.AreEqual(123, employeeExternal.EmployeeCode);
        }
        public void Should_return_none()
        {
            var employeeRepository = MockRepository.GenerateStub<IGenericRepository<Employee>>();

            var mockEmployees = new List<Employee>();

            employeeRepository.Stub(x => x.Get())
                              .IgnoreArguments()
                              .Return(mockEmployees);

            IEmployeeManagement employeeManagement = new EmployeeManagement(employeeRepository);

            EmployeeExternal employeeExternal = employeeManagement.RetrieveByEmployeeCode(888);

            Assert.IsNull(employeeExternal);
        }
        public void None_after_date_should_return_zero()
        {
            var employeeRepository = MockRepository.GenerateStub<IGenericRepository<Employee>>();

            var mockEmployees = new List<Employee>();

            employeeRepository.Stub(x => x.Get())
                              .IgnoreArguments()
                              .Return(mockEmployees);

            IEmployeeManagement employeeManagement = new EmployeeManagement(employeeRepository);

            List<EmployeeExternal> employeeExternalList = employeeManagement.RetrieveAfterStartDate(Convert.ToDateTime("18/Dec/2020"));

            Assert.AreEqual(0, employeeExternalList.Count);
        }
        public void Exists_should_return_one()
        {
            var employeeRepository = MockRepository.GenerateStub<IGenericRepository<Employee>>();

            var mockEmployees = new List<Employee> {new Employee {ID = 1, EmployeeCode = 123, Name = "Stephen"}};

            employeeRepository.Stub(x => x.Get())
                              .IgnoreArguments()
                              .Return(mockEmployees);

            IEmployeeManagement employeeManagement = new EmployeeManagement(employeeRepository);

            List<EmployeeExternal> employeeExternalList = employeeManagement.RetrieveByName("Stephen");

            Assert.IsTrue(employeeExternalList[0].Name == "Stephen");
        }
        public void Does_not_exists_should_return_none()
        {
            var employeeRepository = MockRepository.GenerateStub<IGenericRepository<Employee>>();

            var mockEmployees = new List<Employee>();

            employeeRepository.Stub(x => x.Get())
                              .IgnoreArguments()
                              .Return(mockEmployees);

            IEmployeeManagement employeeManagement = new EmployeeManagement(employeeRepository);

            List<EmployeeExternal> employeeExternalList = employeeManagement.RetrieveByName("XXXX");

            Assert.AreEqual(0, employeeExternalList.Count);
        }
Esempio n. 8
0
        public void Should_insert()
        {
            var employeeRepository = MockRepository.GenerateStub<IGenericRepository<Employee>>();

            var employee = new EmployeeExternal
            {
                ID = 6,
                EmployeeCode = 562,
                Name = "TEST",
                StartDate = Convert.ToDateTime("18/Jan/2009")
            };

            IEmployeeManagement employeeManagement = new EmployeeManagement(employeeRepository);

            employeeManagement.AddEmployee(employee);
        }
        public void Three_exists_should_return_three()
        {
            var employeeRepository = MockRepository.GenerateStub<IGenericRepository<Employee>>();

            var mockEmployees = new List<Employee>
                                    {
                                        new Employee {ID = 1, EmployeeCode = 123, Name = "Fred"},
                                        new Employee {ID = 2, EmployeeCode = 456, Name = "Fred"},
                                        new Employee {ID = 3, EmployeeCode = 789, Name = "Fred"}
                                    };

            employeeRepository.Stub(x => x.Get())
                              .IgnoreArguments()
                              .Return(mockEmployees);

            IEmployeeManagement employeeManagement = new EmployeeManagement(employeeRepository);

            List<EmployeeExternal> employeeExternalList = employeeManagement.RetrieveByName("Fred");

            Assert.AreEqual(3, employeeExternalList.Count);
        }