public void UpdateEmployeeStatus_Should_Return_Employee_TypeOf_ListEmployeeDetailsModel_If_Employee_Exists()
        {
            // Arrange
            var employeeToReturn = new Employee
            {
                FirstName   = "Alex",
                LastName    = "Alexov",
                Email       = "*****@*****.**",
                PhoneNumber = "123456789"
            };

            mapperStub.Setup(x => x.Map <Employee>(It.IsAny <CreateEmployeeModel>())).Returns(employeeToReturn);

            createEmployeeService.Execute(new List <string>()
            {
                "createEmployee", "Alex", "Alexov", "*****@*****.**", "123456789"
            });

            // Act
            updateEmployeeStatusService.Execute(new List <string>()
            {
                "updateEmployeeStatus", "*****@*****.**", "1"
            });

            var employeeExists = this.dbStub
                                 .Employees
                                 .Where(e => e.Email == "*****@*****.**")
                                 .ProjectTo <ListEmployeeDetailsModel>()
                                 .SingleOrDefault();

            // Assert
            Assert.IsInstanceOfType(employeeExists, typeof(ListEmployeeDetailsModel));
        }
예제 #2
0
        public void ListEmployeeDetails_Should_Find_Concrete_Employee()
        {
            // Arrange
            var employeeToReturn = new Employee
            {
                FirstName   = "Alex",
                LastName    = "Alexov",
                Email       = "*****@*****.**",
                PhoneNumber = "123456789"
            };

            mapperStub.Setup(x => x.Map <Employee>(It.IsAny <CreateEmployeeModel>())).Returns(employeeToReturn);

            createEmployeeService.Execute(new List <string>()
            {
                "createEmployee", "Alex", "Alexov", "*****@*****.**", "123456789"
            });

            // Act
            listEmployeeDetailsService.Execute(new List <string>()
            {
                "listemployeedetails", "*****@*****.**"
            });

            var employee = this.dbStub
                           .Employees
                           .Where(e => e.Email == "*****@*****.**")
                           .ProjectTo <ListEmployeeDetailsModel>()
                           .SingleOrDefault();

            // Assert
            Assert.AreEqual("Alex", employee.FirstName);
            Assert.AreEqual("Alexov", employee.LastName);
            Assert.AreEqual("*****@*****.**", employee.Email);
        }
        public void ListEmployees_Should_Return_EmployeesList_TypeOf_ListEmployeesModel_If_Employees_Exist()
        {
            // Arrange
            var employeeToReturn = new Employee
            {
                FirstName   = "Alex",
                LastName    = "Alexov",
                Email       = "*****@*****.**",
                PhoneNumber = "123456789"
            };

            mapperStub.Setup(x => x.Map <Employee>(It.IsAny <CreateEmployeeModel>())).Returns(employeeToReturn);

            createEmployeeService.Execute(new List <string>()
            {
                "createEmployee", "Alex", "Alexov", "*****@*****.**", "123456789"
            });

            // Act
            listEmployeesService.Execute(new List <string>()
            {
                "listEmployees"
            });

            var employees = this.dbStub
                            .Employees
                            .ProjectTo <ListEmployeesModel>()
                            .ToList();

            // Assert
            Assert.IsInstanceOfType(employees, typeof(List <ListEmployeesModel>));
        }
예제 #4
0
        public void CreateEmployee_Should_Throw_ArgumentException_If_No_Params_Are_Passed()
        {
            // Arrange
            var parameters = new List <string>()
            {
                "createEmployee"
            };

            // Act && Assert
            Assert.ThrowsException <ArgumentException>(() => createEmployeeService.Execute(parameters));
        }
        public void ListEmployeesByStatus_Should_Return_All_Employees_With_That_Status()
        {
            // Arrange
            var employeeToReturn = new Employee
            {
                FirstName   = "Alex",
                LastName    = "Alexov",
                Email       = "*****@*****.**",
                PhoneNumber = "123456789"
            };

            mapperStub.Setup(x => x.Map <Employee>(It.IsAny <CreateEmployeeModel>())).Returns(employeeToReturn);

            // Act
            createEmployeeService.Execute(new List <string>()
            {
                "createEmployee", "Alex", "Alexov", "*****@*****.**", "123456789"
            });

            var employee = this.dbStub.Employees.SingleOrDefault(e => e.Email == "*****@*****.**");

            var status = EmployeeStatus.Assigned;

            employee.Status = status;
            dbStub.SaveChanges();


            // Act
            listEmployeesByStatusService.Execute(new List <string>()
            {
                "listEmployeesByStatus", "Assigned"
            });

            var employees = this.dbStub
                            .Employees
                            .Where(e => e.Status == status)
                            .ProjectTo <ListEmployeesByStatusModel>()
                            .ToList();

            // Assert
            Assert.IsNotNull(employees);
            Assert.AreEqual(status, employees[0].Status);
        }
        public void ListEmployees_Should_Call_PrintInfo_Of_All_Employees()
        {
            // Arrange
            var employeeToReturn = new Employee
            {
                FirstName   = "Alex",
                LastName    = "Alexov",
                Email       = "*****@*****.**",
                PhoneNumber = "123456789"
            };

            mapperStub.Setup(x => x.Map <Employee>(It.IsAny <CreateEmployeeModel>())).Returns(employeeToReturn);

            var createEmployeeService = new CreateEmployee(dbStub, writerStub.Object, mapperStub.Object);

            createEmployeeService.Execute(new List <string>()
            {
                "createEmployee", "Alex", "Alexov", "*****@*****.**", "123456789"
            });

            var listEmployeesService = new ListEmployees(dbStub, writerStub.Object);

            // Act
            listEmployeesService.Execute(new List <string>()
            {
                "listemployees"
            });

            var employees = this.dbStub
                            .Employees
                            .ProjectTo <ListEmployeesModel>()
                            .ToList();

            // Assert
            Assert.IsNotNull(employees);
            Assert.AreEqual("Alex", employees[0].FirstName);
            Assert.AreEqual("Alexov", employees[0].LastName);
            Assert.AreEqual("*****@*****.**", employees[0].Email);
        }