Beispiel #1
0
        public void EmployeeDL_GetAll_Return_Empty()
        {
            //arrange
            List <Employee>    employees     = null;
            List <EmployeeDto> expectedValue = null;
            var dl = new EmployeeDL(_mockEmployeeRepository.Object, _mockMapper.Object);

            _mockEmployeeRepository.Setup(x => x.All()).Returns((List <Employee>)null);
            _mockMapper.Setup(x => x.Map <IEnumerable <EmployeeDto> >(employees)).Returns(expectedValue);

            //act
            var result = dl.GetAll();

            //assert
            Assert.AreEqual(expectedValue, result);
        }
Beispiel #2
0
        public void EmployeeDL_GetAll_Return_List()
        {
            //arrange
            var employees = new List <Employee> {
                new Employee {
                    Id = 1, FirstName = "John", LastName = "Smith"
                },
                new Employee {
                    Id = 2, FirstName = "Mark", LastName = "Stan"
                },
                new Employee {
                    Id = 3, FirstName = "Eric", LastName = "Lee"
                },
                new Employee {
                    Id = 4, FirstName = "Grace", LastName = "Rock"
                }
            };
            var expectedValue = new List <EmployeeDto> {
                new EmployeeDto {
                    Id = 1, FirstName = "John", LastName = "Smith"
                },
                new EmployeeDto {
                    Id = 2, FirstName = "Mark", LastName = "Stan"
                },
                new EmployeeDto {
                    Id = 3, FirstName = "Eric", LastName = "Lee"
                },
                new EmployeeDto {
                    Id = 4, FirstName = "Grace", LastName = "Rock"
                }
            };
            var dl = new EmployeeDL(_mockEmployeeRepository.Object, _mockMapper.Object);

            _mockEmployeeRepository.Setup(x => x.All()).Returns(employees);
            _mockMapper.Setup(x => x.Map <IEnumerable <EmployeeDto> >(employees)).Returns(expectedValue);

            //act
            var result = dl.GetAll();

            //assert
            Assert.AreEqual(expectedValue.Count, result.Count());
        }