コード例 #1
0
        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);
        }
コード例 #2
0
        public void Existing_should_be_deleted()
        {
            var employeeRepository = MockRepository.GenerateStub<IGenericRepository<Employee>>();

            IEmployeeManagement employeeManagement = new EmployeeManagement(employeeRepository);

            employeeManagement.DeleteEmployee(6);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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");
        }
コード例 #7
0
        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);
        }
コード例 #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);
        }
コード例 #9
0
        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);
        }