Ejemplo n.º 1
0
        public async void GetAllEmployeesAsync_ShouldReturnEmployeesList()
        {
            // Arrange
            var employees = new List <Employee>
            {
                new Employee
                {
                    Id        = 1,
                    FirstName = "John",
                    LastName  = "Dou",
                    MediaInteractivaEmployee = true,
                    Pet = new Pet {
                        Id = 32, Name = "Dick", Type = "duck", OwnerId = 1
                    }
                },
                new Employee
                {
                    Id        = 2,
                    FirstName = "Sam",
                    LastName  = "Smith",
                    MediaInteractivaEmployee = false,
                    Pet = new Pet {
                        Id = 45, Name = "Mat", Type = "cat", OwnerId = 2
                    }
                }
            };

            var employeesRepoMock = new Mock <IBaseRepository <Employee> >();

            employeesRepoMock.Setup(x => x.GetAllAsync()).ReturnsAsync(employees);

            var employeesService = new EmployeesService(employeesRepoMock.Object);

            // Act
            var result = await employeesService.GetAllEmployeesAsync();

            // Arrange
            Assert.IsAssignableFrom <IEnumerable <Employee> >(result);
            Assert.Equal(employees.Count, result.Count());
        }