public void TestGetProject() { TaskManagerController taskManagerController = new TaskManagerController(); taskManagerController.AddProject(new Models.Project() { Name = "Pro1", StartDate = DateTime.Now.ToShortDateString(), EndDate = DateTime.Now.AddDays(10).ToShortDateString(), Priority = 10 }); taskManagerController.AddProject(new Models.Project() { Name = "Pro2", StartDate = DateTime.Now.ToShortDateString(), EndDate = DateTime.Now.AddDays(10).ToShortDateString(), Priority = 10 }); IEnumerable <Project> projects = taskManagerController.GetAllProjects(); Assert.IsNotNull(projects); int projectId = projects.FirstOrDefault().ProjectId; Project project = taskManagerController.GetProject(projectId); Assert.IsNotNull(project); }
public void TestAddProject() { TaskManagerController taskManagerController = new TaskManagerController(); taskManagerController.AddProject(new Models.Project() { Name = "AddProject", StartDate = DateTime.Now.ToShortDateString(), EndDate = DateTime.Now.AddDays(10).ToShortDateString(), Priority = 10 }); IEnumerable <Project> projects = taskManagerController.GetAllProjects(); Assert.IsNotNull(projects); Assert.IsNotNull(projects.Where(t => t.Name == "AddProject").First()); }
public void TestUpdateProject() { TaskManagerController taskManagerController = new TaskManagerController(); taskManagerController.AddProject(new Models.Project() { Name = "ProjectUpdated", StartDate = DateTime.Now.ToShortDateString(), EndDate = DateTime.Now.AddDays(10).ToShortDateString(), Priority = 10 }); IEnumerable <Project> projects = taskManagerController.GetAllProjects(); Assert.IsNotNull(projects); Project project = projects.Where(p => p.Name == "ProjectUpdated").FirstOrDefault(); string newName = project.Name + "Renamed"; project.Name = newName; project.StartDate = DateTime.ParseExact(project.StartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture) .ToString("MM/dd/yyyy", CultureInfo.InvariantCulture).ToString(); project.EndDate = DateTime.ParseExact(project.EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture) .ToString("MM/dd/yyyy", CultureInfo.InvariantCulture).ToString(); taskManagerController.UpdateProject(project); project = taskManagerController.GetProject(project.ProjectId); Assert.IsTrue(project.Name == newName); }