public void RemoveEmployeeFromProjectTest()
        {
            ProjectSqlDAO projectSqlDAO = new ProjectSqlDAO(connectionString);
            bool          result        = projectSqlDAO.RemoveEmployeeFromProject(1, 1);

            Assert.AreEqual(true, result);
        }
        public void RemoveEmployeeFromProjectTest()
        {
            ProjectSqlDAO access = new ProjectSqlDAO(connectionString);
            //Do we need to add a project and an employee for this, or is this ok?
            bool result = access.RemoveEmployeeFromProject(1, 3);

            Assert.IsTrue(result);

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();

                string sql_select = "SELECT * FROM project_employee WHERE project_id = 1 AND employee_id = 3;";

                SqlCommand cmd = new SqlCommand(sql_select, conn);

                SqlDataReader reader = cmd.ExecuteReader();

                int count = 0;

                while (reader.Read())
                {
                    count++;
                }

                Assert.AreEqual(0, count);
            }
        }
Пример #3
0
        public void TestRemoveEmployeeFromProject()
        {
            ProjectSqlDAO project = new ProjectSqlDAO(connectionString);
            //Project deathStarProject = new Project("DeathStarQualityControl", DateTime.Now, DateTime.Now);
            //project.CreateProject(deathStarProject);
            //bool result = project.AssignEmployeeToProject(8, 14);
            bool result2 = project.RemoveEmployeeFromProject(1, 2);

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();

                string sql_select = "SELECT * FROM project_employee WHERE employee_id = 2 AND project_id = 1;";

                SqlCommand cmd = new SqlCommand(sql_select, conn);

                SqlDataReader reader = cmd.ExecuteReader();

                int count = 0;

                while (reader.Read())
                {
                    count++;
                }

                Assert.AreEqual(0, count);
            }
        }
Пример #4
0
        public void Remove_employee_from_project_Test()
        {
            ProjectSqlDAO removeEm = new ProjectSqlDAO(ConnectionString);

            bool result = removeEm.RemoveEmployeeFromProject(project_id, employee_id);

            Assert.IsTrue(result);
        }
Пример #5
0
        public void RemoveEmployeeFromProjectTest()
        {
            ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString);

            bool result = dao.RemoveEmployeeFromProject(testProjectId, testEmpId2);

            Assert.IsTrue(result);
        }
Пример #6
0
        public void RemoveEmployeeFromProject_Should_Remove_Row()
        {
            ProjectSqlDAO dao             = new ProjectSqlDAO(ConnectionString);
            int           initialRowCount = GetRowCount("project_employee");

            bool removed = dao.RemoveEmployeeFromProject(ProjectId, AssignedEmployeeId);

            Assert.IsTrue(removed);
            Assert.AreEqual(initialRowCount - 1, GetRowCount("project_employee"));
        }
        public void TestRemoveEmployeeFromProject()
        {
            ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString);
            int           startingRowCount = GetRowCount("project_employee");

            dao.RemoveEmployeeFromProject(NewProjectId, NewEmployeeId);

            int endingRowCount = GetRowCount("project_employee");

            Assert.AreEqual(startingRowCount - 1, endingRowCount);
        }
Пример #8
0
        public void RemoveEmployeeFromAProjectTest()
        {
            // Arrange
            ProjectSqlDAO project = new ProjectSqlDAO(ConnectionString);

            // Act
            bool isRemoved = project.RemoveEmployeeFromProject(NewProjId, NewEmployeeId2);

            // Assert
            Assert.AreEqual(true, isRemoved);
        }
Пример #9
0
        public void RemoveEmployeeFromProjectTest()
        {
            int projectId;
            int employeeId;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("SELECT employee_id FROM employee WHERE first_name = 'Jarred' and Last_name = 'Lukach'", conn);
                employeeId = Convert.ToInt32(cmd.ExecuteScalar());
                cmd        = new SqlCommand("SELECT project_id FROM project WHERE name = 'Plan 9'", conn);
                projectId  = Convert.ToInt32(cmd.ExecuteScalar());
            }
            bool result = dao.RemoveEmployeeFromProject(projectId, employeeId);

            Assert.AreEqual(true, result);
        }
Пример #10
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");
        }
Пример #11
0
        public void RemoveEmployeeFromProject_ShouldReturnRightNumberOfEmployees()
        {
            //Arrange
            const int numberOfEmployeesWithoutProjects = 2;//set in sql test setup file plus the one employee removed here

            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
            projectDao.RemoveEmployeeFromProject(projects[0].ProjectId, testEmployee[0].EmployeeId);//remove employee with project from the only project


            //Assert
            Assert.AreEqual(numberOfEmployeesWithoutProjects, empDao.GetEmployeesWithoutProjects().Count, "Remove Employee doesn't return correct number when employee removed");
        }