public ProjectViewModel(Project project) { Title = project.Title; Description = project.Description; Velocity = project.Velocity; Id = project.Id; }
public void CanFindAllByUserToken() { var project = new Project(); project.Title = "loooooooo"; project.Description = "loooe3rewrrewooooo"; var project2 = new Project(); project2.Title = "ssss"; project.Description = "loooe3rewrrewooooo"; DatabaseOperationResponse response = m_repository.Save(project); Assert.IsTrue(response.HasSucceeded); response = m_repository.Save(project2); Assert.IsTrue(response.HasSucceeded); var token = "yuiu-998"; m_database.Users.Insert(UserName: "******", FirstName: "Some", LastName: "Dude", APIKey: token, Email: "*****@*****.**", Privileges: 2, Password: "******"); List<Project> dbProjects = m_database.Projects.All().ToList<Project>(); long userId = m_database.Users.All().ToList<User>()[0].Id; m_database.UsersXProjects.Insert(UserId: userId, ProjectId: dbProjects[0].Id); m_database.UsersXProjects.Insert(UserId: userId, ProjectId: dbProjects[1].Id); List<Project> projects = m_repository.GetProjectsByUseToken(token).ConvertAll(e=>(Project)e); Assert.AreEqual(2, projects.Count); }
public ProjectEditModel(Project project,List<User> availableUsers ) { Title = project.Title; Description = project.Description; Id = project.Id; Members = project.Users != null ? project.Users.ConvertAll(e => new MemberViewModel(e)) : new List<MemberViewModel>(); AvailableMembers = availableUsers != null ? availableUsers.ConvertAll(e => new MemberViewModel(e)) : new List<MemberViewModel>(); }
public void CanCreateProject() { var project = new Project {Description = "re"}; var projectRepo = new Mock<IProjectRepository>(MockBehavior.Strict); var apiToken = "key"; projectRepo.Setup(e => e.CreateProjectAssociatedWithKey(project, apiToken)).Returns(new DatabaseOperationResponse(true)); new CharcoalProjectProvider(apiToken, projectRepo.Object).CreateProject(project); projectRepo.Verify(); }
public void CanFindAll() { var project = new Project(); project.Title = "loooooooo"; project.Description = "loooe3rewrrewooooo"; DatabaseOperationResponse response = m_repository.Save(project); Assert.IsTrue(response.HasSucceeded); Project retrievedProject = m_database.Projects.All().ToList<Project>()[0]; List<Project> projects = m_repository.FindAll().ConvertAll(e=>(Project)e); Assert.AreEqual(1, projects.Count); VerifyProject(retrievedProject, projects[0]); }
public void CanDeleteExistingProject() { var project = new Project(); project.Title = "loooooooo"; project.Description = "loooe3rewrrewooooo"; DatabaseOperationResponse response = m_repository.Save(project); Assert.IsTrue(response.HasSucceeded); Project retrievedProject = m_database.Projects.All().ToList<Project>()[0]; response = m_repository.Delete(retrievedProject.Id); Assert.IsTrue(response.HasSucceeded); var projects = m_database.Projects.All().ToList<User>(); Assert.AreEqual(0, projects.Count); }
public void CanCreateProjectAssociatedWithKey() { var project = new Project(); project.Title = "loooooooo"; project.Description = "loooe3rewrrewooooo"; var user = m_database.Users.Insert(UserName: "******", FirstName: "Some", LastName: "Dude", APIKey: "yuiu-998", Email: "*****@*****.**", Privileges: 2, Password: "******"); var response = m_repository.CreateProjectAssociatedWithKey(project, user.APIKey); Assert.IsTrue(response.HasSucceeded); Assert.AreEqual(1, m_database.Projects.All().ToList<Project>().Count); var projects = m_repository.GetProjectsByUseToken(user.APIKey); Assert.AreEqual(1, projects.Count); }
public OperationResponse CreateProject(Project project) { var response= m_projectRepository.CreateProjectAssociatedWithKey(project, m_token); return new OperationResponse(response.HasSucceeded, response.Description); }
private void VerifyProject(Project expected, Project actual) { Assert.AreEqual(expected.Title, actual.Title); Assert.AreEqual(expected.Description, actual.Description); Assert.AreEqual(expected.Velocity, actual.Velocity); }
public void CanSaveProject() { var project = new Project(); project.Title = "loooooooo"; project.Description = "loooe3rewrrewooooo"; project.Velocity = 32; DatabaseOperationResponse response = m_repository.Save(project); Assert.IsTrue(response.HasSucceeded); var projects = m_database.Projects.All().ToList<Project>(); Assert.AreEqual(1, projects.Count); VerifyProject(project, projects[0]); }
public void CanFindById() { var project = new Project(); project.Title = "loooooooo"; project.Description = "loooe3rewrrewooooo"; DatabaseOperationResponse response = m_repository.Save(project); Assert.IsTrue(response.HasSucceeded); Project retrievedProject = m_database.Projects.All().ToList<Project>()[0]; Project foundUser = m_repository.Find(retrievedProject.Id); VerifyProject(retrievedProject, foundUser); }