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 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 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 CreateProject_ShouldReturnRightNumberOfProjects() { //Arrange const int numberOfProjectsAfterCreated = 2;//set in sql test setup file plus the one we are creating here ProjectSqlDAO dao = new ProjectSqlDAO(ConnectionString); Project newProject = new Project(); newProject.Name = "create test"; newProject.StartDate = Convert.ToDateTime("2020-02-19"); newProject.EndDate = Convert.ToDateTime("2020-02-19"); //Act dao.CreateProject(newProject); //Assert Assert.AreEqual(numberOfProjectsAfterCreated, dao.GetAllProjects().Count); }
public void CreateANewProject() { // Arrange Project proj = new Project(); proj.Name = "book reading"; proj.StartDate = Convert.ToDateTime("2020-01-01"); proj.EndDate = Convert.ToDateTime("2020-04-30"); ProjectSqlDAO projsql = new ProjectSqlDAO(ConnectionString); int startCount = GetRowCount("project"); // Act projsql.CreateProject(proj); int endCount = GetRowCount("project"); // Assert Assert.AreEqual(startCount + 1, endCount); }
public void CreateProject_ShouldReturnAProject() { // Arrange ProjectSqlDAO project = new ProjectSqlDAO(ConnectionString); Project newProject = new Project(); newProject.Name = "TestProject"; //newProject.ProjectId = 2; newProject.StartDate = new DateTime(2020, 10, 20); newProject.EndDate = new DateTime(2020, 10, 21); int startingRowCount = GetRowCount("project"); // Act project.CreateProject(newProject); int endingRowCount = GetRowCount("project"); // Assert Assert.AreNotEqual(startingRowCount, endingRowCount); }