public void SearchTest()
        {
            EmployeeSqlDAO  employeeSqlDAO = new EmployeeSqlDAO(connectionString);
            List <Employee> employeesList  = (List <Employee>)employeeSqlDAO.Search("Sid", "Goodman");

            Assert.AreEqual(1, employeesList.Count);
        }
Ejemplo n.º 2
0
        public void EmployeeSearch_Should_Return_Correct_Results(string firstName, string lastName, int expectedCount)
        {
            EmployeeSqlDAO   dao       = new EmployeeSqlDAO(ConnectionString);
            IList <Employee> employees = dao.Search(firstName, lastName);

            Assert.AreEqual(expectedCount, employees.Count);
        }
        public void GetEmployeesWithoutProjectsTest()
        {
            EmployeeSqlDAO  employeeSqlDAO = new EmployeeSqlDAO(connectionString);
            List <Employee> employeesList  = (List <Employee>)employeeSqlDAO.GetEmployeesWithoutProjects();

            Assert.AreEqual(2, employeesList.Count);
        }
Ejemplo n.º 4
0
        public void Get_employees_not_assigned_to_tests()
        {
            EmployeeSqlDAO  employeesNotAssigned = new EmployeeSqlDAO(ConnectionString);
            List <Employee> noProjectList        = (List <Employee>)employeesNotAssigned.GetEmployeesWithoutProjects();

            Assert.AreEqual(projectID, noProjectList.Count);
        }
        public void GetAllEmployeesTest()
        {
            EmployeeSqlDAO  employeeSqlDAO = new EmployeeSqlDAO(connectionString);
            List <Employee> employeesList  = (List <Employee>)employeeSqlDAO.GetAllEmployees();

            Assert.AreEqual(12, employeesList.Count);
        }
Ejemplo n.º 6
0
        public void GetAllEmployees_Should_Return_Correct_Count()
        {
            EmployeeSqlDAO   dao       = new EmployeeSqlDAO(ConnectionString);
            IList <Employee> employees = dao.GetAllEmployees();

            Assert.AreEqual(2, employees.Count);
        }
Ejemplo n.º 7
0
        public void GetEmployeesWithoutProjects_Test()
        {
            EmployeeSqlDAO   accessObj             = new EmployeeSqlDAO(connectionString);
            IList <Employee> listOfEmployeesToFire = accessObj.GetEmployeesWithoutProjects();

            Assert.AreEqual(3, listOfEmployeesToFire.Count);
        }
Ejemplo n.º 8
0
        public void Search_Test()
        {
            EmployeeSqlDAO   accessObj = new EmployeeSqlDAO(connectionString);
            IList <Employee> listofMatchedEmployess = accessObj.Search("JoEli", "Collinsall");

            Assert.AreEqual(1, listofMatchedEmployess.Count);
        }
Ejemplo n.º 9
0
        public void GetEmployeesWithoutProjects_Should_Return_Correct_Count()
        {
            EmployeeSqlDAO   dao       = new EmployeeSqlDAO(ConnectionString);
            IList <Employee> employees = dao.GetEmployeesWithoutProjects();

            Assert.AreEqual(1, employees.Count);
            Assert.AreEqual(UnassignedEmployeeId, employees[0].EmployeeId);
        }
Ejemplo n.º 10
0
        public void TestSearch()
        {
            EmployeeSqlDAO dao = new EmployeeSqlDAO(ConnectionString);

            IList <Employee> result = dao.Search("pe", "pe");

            Assert.AreEqual(NewEmployeeId, result[0].EmployeeId);
        }
Ejemplo n.º 11
0
        public void TestGetEmployeesWithoutProjects()
        {
            EmployeeSqlDAO dao = new EmployeeSqlDAO(ConnectionString);

            IList <Employee> result = dao.GetEmployeesWithoutProjects();

            Assert.AreEqual(NewEmployeeId2, result[0].EmployeeId);
        }
Ejemplo n.º 12
0
        public void Search_Test()
        {
            EmployeeSqlDAO  getEmployee = new EmployeeSqlDAO(ConnectionString);
            List <Employee> searchTest  = (List <Employee>)getEmployee.Search("TheFun", "Employee");

            CollectionAssert.AllItemsAreNotNull(searchTest);
            Assert.AreEqual(1, searchTest.Count);
            Equals("TheFun", searchTest[0].FirstName);
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            IProjectDAO    projectDAO    = new ProjectSqlDAO(@"Data Source =.\SQLEXPRESS; Initial Catalog = EmployeeDB; Integrated Security = True");
            IEmployeeDAO   employeeDAO   = new EmployeeSqlDAO(@"Data Source =.\SQLEXPRESS; Initial Catalog = EmployeeDB; Integrated Security = True");
            IDepartmentDAO departmentDAO = new DepartmentSqlDAO(@"Data Source =.\SQLEXPRESS; Initial Catalog = EmployeeDB; Integrated Security = True");

            ProjectCLI projectCLI = new ProjectCLI(employeeDAO, projectDAO, departmentDAO);

            projectCLI.RunCLI();
        }
Ejemplo n.º 14
0
        public void SearchForEmployeeTest()
        {
            // Arrange
            EmployeeSqlDAO employee = new EmployeeSqlDAO(ConnectionString);

            // Act
            IList <Employee> employees = employee.Search("Sarah", "Watkins");

            // Assert
            Assert.AreEqual(1, employees.Count);
        }
Ejemplo n.º 15
0
        public void GetEmployeesWithoutProjectsTest()
        {
            // Arrange
            EmployeeSqlDAO employee = new EmployeeSqlDAO(ConnectionString);

            // Act
            IList <Employee> employees = employee.GetEmployeesWithoutProjects();

            // Assert
            Assert.AreEqual(1, employees.Count);
        }
Ejemplo n.º 16
0
        public void TestGetAllEmployees()
        {
            // Arrange
            EmployeeSqlDAO dao = new EmployeeSqlDAO(ConnectionString);

            //ACT
            IList <Employee> result = dao.GetAllEmployees();

            //ASERT
            Assert.AreEqual(GetRowCount("employee"), result.Count);
        }
Ejemplo n.º 17
0
        public void GetEmployeesWithoutProjectsTest()
        {
            EmployeeSqlDAO dao = new EmployeeSqlDAO(ConnectionString);

            IList <Employee> iemployees = dao.GetEmployeesWithoutProjects();
            List <Employee>  employees  = iemployees.ToList();

            Assert.IsNotNull(employees);
            Assert.IsTrue(employees.Count > 0);
            Assert.IsNotNull(employees.Find(e => e.EmployeeId == testEmployeeId));
            Assert.IsNull(employees.Find(e => e.EmployeeId == testEmployeeIdAssignedToProject));
        }
Ejemplo n.º 18
0
        public void Get_Employee_Test()
        {
            //Arrange

            EmployeeSqlDAO getEmployee = new EmployeeSqlDAO(ConnectionString);

            List <Employee> employeeList = (List <Employee>)getEmployee.GetAllEmployees();

            //Assert
            Assert.IsNotNull(employeeList);
            Assert.AreEqual(numberOfEmployees + 1, employeeList.Count);
        }
Ejemplo n.º 19
0
        public void GetAllEmployees_ShouldReturnEmployees()
        {
            //Arrange
            EmployeeSqlDAO employee = new EmployeeSqlDAO(ConnectionString);


            //Act
            int result = employee.GetAllEmployees().Count;


            //Assert
            Assert.AreEqual(1, result);
        }
Ejemplo n.º 20
0
        public void GetAllEmployees_ShouldReturnRightNumberOfEmployees()
        {
            //Arrange
            const int numberOfEmployeesAddedForTests = 2;//set in sql test setup file

            EmployeeSqlDAO dao = new EmployeeSqlDAO(ConnectionString);

            //Act
            IList <Employee> employees = dao.GetAllEmployees();

            //Assert
            Assert.AreEqual(numberOfEmployeesAddedForTests, employees.Count, "GetAllEmployees doesn't return correct number for one employee");
        }
Ejemplo n.º 21
0
        public void GetAllEmployeesTest()
        {
            // Arrange

            EmployeeSqlDAO employee = new EmployeeSqlDAO(ConnectionString);

            // Act

            IList <Employee> employees = employee.GetAllEmployees();

            // Assert
            Assert.AreEqual(2, employees.Count);
        }
Ejemplo n.º 22
0
        public void SearchTest()
        {
            EmployeeSqlDAO dao = new EmployeeSqlDAO(ConnectionString);

            IList <Employee> employees = dao.Search("First Name", "Last Name");

            Assert.IsNotNull(employees);
            Assert.IsTrue(employees.Count > 0);
            Employee testEmployee = employees.Where(e => e.EmployeeId == testEmployeeId).FirstOrDefault();

            Assert.IsNotNull(testEmployee);
            Assert.AreEqual("First Name", testEmployee.FirstName);
            Assert.AreEqual("Last Name", testEmployee.LastName);
        }
Ejemplo n.º 23
0
        public void GetEmployeesWithoutProjects_ShouldGetCorrectNumEmployees()
        {
            //Arrange
            EmployeeSqlDAO dao = new EmployeeSqlDAO(ConnectionString);
            const int      numberOfEmployeesAddedWithoutPojects = 1;//set in sql test setup file


            //Act

            IList <Employee> employees = dao.GetEmployeesWithoutProjects();


            //Assert

            Assert.AreEqual(numberOfEmployeesAddedWithoutPojects, employees.Count);
        }
Ejemplo n.º 24
0
        public void GetAllEmployees_Test()
        {
            EmployeeSqlDAO   accessObj = new EmployeeSqlDAO(connectionString);
            IList <Employee> items     = accessObj.GetAllEmployees();

            bool found = false;

            foreach (Employee loopItem in items)
            {
                if (loopItem.LastName == "Collinsall")
                {
                    found = true;
                    break;
                }
            }
            Assert.IsTrue(found);
        }
Ejemplo n.º 25
0
        public void TestSearch()
        {
            EmployeeSqlDAO   employee           = new EmployeeSqlDAO(connectionString);
            IList <Employee> employeeSearchList = employee.Search("JB", "Martin");

            bool result = false;

            foreach (Employee person in employeeSearchList)
            {
                if (person.FirstName == "JB")
                {
                    result = true;
                    break;
                }
            }

            Assert.IsTrue(result);
        }
Ejemplo n.º 26
0
        public void TestGetAllEmployees()
        {
            EmployeeSqlDAO   employee     = new EmployeeSqlDAO(connectionString);
            IList <Employee> employeeList = employee.GetAllEmployees();

            bool found = false;

            foreach (Employee person in employeeList)
            {
                if (person.JobTitle == "TRAITOR")
                {
                    found = true;
                    break;
                }
            }

            Assert.IsTrue(found);
        }
Ejemplo n.º 27
0
        static void Main(string[] args)
        {
            // Get the connection string from the appsettings.json file
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .SetBasePath(Directory.GetCurrentDirectory())
                                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("Project");

            IProjectDAO    projectDAO    = new ProjectSqlDAO(connectionString);
            IEmployeeDAO   employeeDAO   = new EmployeeSqlDAO(connectionString);
            IDepartmentDAO departmentDAO = new DepartmentSqlDAO(connectionString);

            ProjectCLI projectCLI = new ProjectCLI(employeeDAO, projectDAO, departmentDAO);

            projectCLI.RunCLI();
        }
Ejemplo n.º 28
0
        public void SearchEmployee_ShouldFindEmployeeName(string firstName, string lastName, bool isMatchExpected)
        {
            //Arrange
            EmployeeSqlDAO dao = new EmployeeSqlDAO(ConnectionString);

            const string testValFirstName = "John";//Set in sql test setup file
            const string testValLastName  = "Smith";

            //Act

            IList <Employee> employees = dao.Search(firstName, lastName);

            //list will be empty when search terms aren't in table and when table not empty then check name matches expected
            bool isMatch = employees.Count != 0 && (testValFirstName == employees[0].FirstName) && (testValLastName == employees[0].LastName);//employee[0] set in sql test file

            //Assert

            Assert.AreEqual(isMatchExpected, isMatch);
        }
Ejemplo n.º 29
0
        public void AssignEmployeeToProject_ShouldReturnRightNumberOfEmployees()
        {
            //Arrange
            const int numberOfEmployeesWithoutProjects = 0;//set in sql test setup file minus the one employee assigned here

            ProjectSqlDAO  projectDao = new ProjectSqlDAO(ConnectionString);
            EmployeeSqlDAO empDao     = new EmployeeSqlDAO(ConnectionString);

            IList <Project> projects = projectDao.GetAllProjects();

            IList <Employee> testEmployee = empDao.GetEmployeesWithoutProjects();//Get the employee added in sql test file that does not have a project assigned


            //Act
            projectDao.AssignEmployeeToProject(projects[0].ProjectId, testEmployee[0].EmployeeId);//assign employee withou project to the only project


            //Assert
            Assert.AreEqual(numberOfEmployeesWithoutProjects, empDao.GetEmployeesWithoutProjects().Count, "GetAllProjects doesn't return correct number for one project");
        }
Ejemplo n.º 30
0
        public void RemoveEmployeeFromProject_ShouldReturnTrueWhenEmployeeRemoved()
        {
            //Arrange
            const bool expectedResult = true;//when employee successfully removed, function should return true

            ProjectSqlDAO  projectDao = new ProjectSqlDAO(ConnectionString);
            EmployeeSqlDAO empDao     = new EmployeeSqlDAO(ConnectionString);


            IList <Project> projects = projectDao.GetAllProjects();

            IList <Employee> testEmployee = empDao.Search("John", "Smith");//Get the employee added in sql test file that does have a project assigned. name from sql test file


            //Act
            bool resultOfRemove = projectDao.RemoveEmployeeFromProject(projects[0].ProjectId, testEmployee[0].EmployeeId);//remove employee with project from the only project


            //Assert
            Assert.AreEqual(expectedResult, resultOfRemove, "RemoveEmployeeFromProject doesn't return true when employee removed");
        }