public void CreateDepartmentTest() { ProjectSqlDAO access = new ProjectSqlDAO(connectionString); Project temp = new Project(); temp.Name = "XXXX"; temp.ProjectId = 50; temp.StartDate = new DateTime(2030, 02, 01); temp.EndDate = new DateTime(2030, 3, 1); int result = access.CreateProject(temp); Assert.AreEqual(50, result); using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); string sql_select = "SELECT * FROM project WHERE name = 'XXXX';"; SqlCommand cmd = new SqlCommand(sql_select, conn); SqlDataReader reader = cmd.ExecuteReader(); int count = 0; while (reader.Read()) { count++; } Assert.AreEqual(1, count); } }
public void RemoveEmployeeFromProjectTest() { ProjectSqlDAO projectSqlDAO = new ProjectSqlDAO(connectionString); bool result = projectSqlDAO.RemoveEmployeeFromProject(1, 1); Assert.AreEqual(true, result); }
public void TestAssignEmployeeToProject() { 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.AssignEmployeeToProject(newProjectId, 4); using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); string sql_select = "SELECT * FROM project_employee WHERE employee_id = 4 AND project_id = @newProjectId;"; SqlCommand cmd = new SqlCommand(sql_select, conn); cmd.Parameters.AddWithValue("@newProjectId", newProjectId); SqlDataReader reader = cmd.ExecuteReader(); int count = 0; while (reader.Read()) { count++; } Assert.AreEqual(1, count); } }
public void GetAllProjects_Should_Return_The_Correct_Count() { ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); IList <Project> projects = dao.GetAllProjects(); Assert.AreEqual(1, projects.Count); }
public void AssignEmployeeToProjectTest() { ProjectSqlDAO access = new ProjectSqlDAO(connectionString); //Do we need to add a project and an employee for this, or is this ok? bool result = access.AssignEmployeeToProject(6, 1); Assert.IsTrue(result); using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); string sql_select = "SELECT * FROM project_employee WHERE project_id = 6 AND employee_id = 1;"; SqlCommand cmd = new SqlCommand(sql_select, conn); SqlDataReader reader = cmd.ExecuteReader(); int count = 0; while (reader.Read()) { count++; } Assert.AreEqual(1, count); } }
public void AssignEmployeeToProjectTest() { ProjectSqlDAO projectSqlDAO = new ProjectSqlDAO(connectionString); bool result = projectSqlDAO.AssignEmployeeToProject(2, 1); Assert.AreEqual(true, result); }
public void GetAllProjectsTest() { ProjectSqlDAO projectSqlDAO = new ProjectSqlDAO(connectionString); List <Project> projectsTest = (List <Project>)projectSqlDAO.GetAllProjects(); Assert.AreEqual(7, projectsTest.Count); }
public void Remove_employee_from_project_Test() { ProjectSqlDAO removeEm = new ProjectSqlDAO(ConnectionString); bool result = removeEm.RemoveEmployeeFromProject(project_id, employee_id); Assert.IsTrue(result); }
public void RemoveEmployeeFromProjectTest() { ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); bool result = dao.RemoveEmployeeFromProject(testProjectId, testEmpId2); Assert.IsTrue(result); }
public void AssignEmployeeToExistingProject() { ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); bool result = dao.AssignEmployeeToProject(testProjectId, testEmpId2); Assert.IsTrue(result); }
public void Arrange() { //arrange //Establish the "known state" of the database SetupDB(); //Create and instance of CountrySqlDAO this.dao = new ProjectSqlDAO(connectionString); }
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")); }
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(); }
public void AssignEmployeeToProject_Should_Add_Row() { ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); int initialRowCount = GetRowCount("project_employee"); bool added = dao.AssignEmployeeToProject(ProjectId, UnassignedEmployeeId); Assert.IsTrue(added); Assert.AreEqual(initialRowCount + 1, GetRowCount("project_employee")); }
public void Assigned_employee_to_project_by_id_Test() { int project_ids = 1; int employee_ids = 1; ProjectSqlDAO assignEm = new ProjectSqlDAO(ConnectionString); bool result = assignEm.AssignEmployeeToProject(project_ids, employee_ids); Assert.IsTrue(result); }
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); }
public void GetProjectsShouldReturnRightNumberofProjects() { // Arrange ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); //ACT IList <Project> project = dao.GetAllProjects(); //ASERT Assert.AreEqual(GetRowCount("project"), project.Count); }
public void GetAllProjectsTest() { ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); IList <Project> iprojects = dao.GetAllProjects(); List <Project> projects = iprojects.ToList(); Assert.IsNotNull(projects); Assert.IsTrue(projects.Count > 0); Assert.IsNotNull(projects.Find(p => p.ProjectId == testProjectId)); }
public void AssignEmployeeToAProjectTest() { // Arrange ProjectSqlDAO project = new ProjectSqlDAO(ConnectionString); // Act bool isAdded = project.AssignEmployeeToProject(NewProjId, NewEmployeeId); // Assert Assert.AreEqual(true, isAdded); }
public void RemoveEmployeeFromAProjectTest() { // Arrange ProjectSqlDAO project = new ProjectSqlDAO(ConnectionString); // Act bool isRemoved = project.RemoveEmployeeFromProject(NewProjId, NewEmployeeId2); // Assert Assert.AreEqual(true, isRemoved); }
public void Get_all_projects_Test() { //Arrange ProjectSqlDAO allProjects = new ProjectSqlDAO(ConnectionString); List <Project> projectList = (List <Project>)allProjects.GetAllProjects(); //Assert Assert.IsNotNull(projectList); Assert.AreEqual(project_id + 1, projectList.Count); }
public void AssignEmployeeToProjectShouldAssignEmployeeToProject() { ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); int startingRowCount = GetRowCount("project_employee"); dao.AssignEmployeeToProject(NewProjectId, NewEmployeeId2); int endingRowCount = GetRowCount("project_employee"); Assert.AreEqual(startingRowCount + 1, endingRowCount); }
public void CreateProjectTest() { ProjectSqlDAO projectSqlDAO = new ProjectSqlDAO(connectionString); Project project = new Project(); project.Name = "test"; project.StartDate = DateTime.Parse("2010-03-19"); project.EndDate = DateTime.Parse("2011-03-19"); Assert.AreEqual("test", project.Name); Assert.AreEqual(DateTime.Parse("2010-03-19"), project.StartDate); Assert.AreEqual(DateTime.Parse("2011-03-19"), project.EndDate); }
public void CreateProject_Should_Add_Row() { ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); int initialRowCount = GetRowCount("project"); int newId = dao.CreateProject(new Project() { Name = "TEST PROJECT 2", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(1) }); Assert.AreEqual(ProjectId + 1, newId); Assert.AreEqual(initialRowCount + 1, GetRowCount("project")); }
public void GetAllProjectsTest() { // Arrange ProjectSqlDAO project = new ProjectSqlDAO(ConnectionString); // Act IList <Project> projects = project.GetAllProjects(); // Assert Assert.AreEqual(1, projects.Count); }
public void GetAllProjects_ShouldReturnRightNumberOfProjects() { //Arrange const int numberOfProjectsAddedForTests = 1;//set in sql test setup file ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); //Act IList <Project> projects = dao.GetAllProjects(); //Assert Assert.AreEqual(numberOfProjectsAddedForTests, projects.Count, "GetAllProjects doesn't return correct number for one project"); }
public void TestCreateProject() { ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); Project SM64 = new Project(); SM64.Name = "Super Mario"; SM64.StartDate = DateTime.Now; SM64.EndDate = DateTime.Now; int result = dao.CreateProject(SM64); Assert.AreEqual(1, result); }
public void TestCreateProject() { ProjectSqlDAO project = new ProjectSqlDAO(connectionString); Project newProject = new Project("DeathStarQualityControl", DateTime.Now, DateTime.Now); int result = project.CreateProject(newProject); bool success = false; if (result > 0) { success = true; } Assert.IsTrue(success); }
public void CreateProjectTest() { int originalCount = GetNumberOfProjects(); ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); Project newProj = new Project { Name = "New Project 2", StartDate = DateTime.Now, EndDate = DateTime.Now }; int result = dao.CreateProject(newProj); Assert.AreEqual(testProjectId + 1, result); Assert.AreEqual(originalCount + 1, GetNumberOfProjects()); }
public void GetAllProjectsTest() { ProjectSqlDAO access = new ProjectSqlDAO(connectionString); IList <Project> items = access.GetAllProjects(); bool found = false; foreach (Project item in items) { if (item.Name == "ZZZZZ") { found = true; break; } } Assert.IsTrue(found); }