Exemplo n.º 1
0
 public static void SetUp(TestContext _context)
 {
     dependency_repo = new DependencyRepository();
     project_repo    = new ProjectsRepository();
     project_repo.Add(new Project("Angular", 1, "03/02/2013", "03/04/2014", "www.github.com/angular"));
     project_repo.Add(new Project("js", 1, "03/02/2013", "03/04/2014", "www.github.com/js"));
     dependency_repo.Clear();
 }
Exemplo n.º 2
0
        public ActionResult Create(Project project, HttpPostedFileBase ProjectImage)
        {
            if (ModelState.IsValid)
            {
                #region Upload Image
                if (ProjectImage != null)
                {
                    // Saving Temp Image
                    var newFileName = Guid.NewGuid() + Path.GetExtension(ProjectImage.FileName);
                    ProjectImage.SaveAs(Server.MapPath("/Files/ProjectImages/Temp/" + newFileName));
                    // Resize Image
                    ImageResizer image = new ImageResizer(840, 385, true);
                    image.Resize(Server.MapPath("/Files/ProjectImages/Temp/" + newFileName),
                                 Server.MapPath("/Files/ProjectImages/Image/" + newFileName));

                    ImageResizer thumb = new ImageResizer(400, 250, true);
                    thumb.Resize(Server.MapPath("/Files/ProjectImages/Temp/" + newFileName),
                                 Server.MapPath("/Files/ProjectImages/Thumb/" + newFileName));

                    // Deleting Temp Image
                    System.IO.File.Delete(Server.MapPath("/Files/ProjectImages/Temp/" + newFileName));

                    project.Image = newFileName;
                }
                #endregion

                _repo.Add(project);
                return(RedirectToAction("Index"));
            }
            ViewBag.ProjectTypeId = new SelectList(_repo.GetProjectTypes(), "Id", "Title", project.ProjectTypeId);
            return(View(project));
        }
Exemplo n.º 3
0
        public void Can_save_project()
        {
            var project = new Project()
            {
                Name      = "Sample Project",
                Id        = Guid.NewGuid(),
                BrowseUrl = "Click to resolve",
                Created   = DateTime.Now,
                Version   = "1.0.0.0"
            };

            project.Location = new ProjectLocation()
            {
                LocalPath = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2", Type = LocationType.FileSystem, Url = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2"
            };

            // serialize
            var xml = XmlSerializationService <Project> .Serialize(project);


            var repository = new ProjectsRepository();

            repository.Add(project);
            repository.UnitOfWork.Commit();

            repository = new ProjectsRepository();
            Assert.True(repository.Projects.Count() == 1);


            var project2 = new Project()
            {
                Name      = "Sample Project 2",
                Id        = Guid.NewGuid(),
                BrowseUrl = "Click to resolve",
                Created   = DateTime.Now,
                Version   = "1.0.0.0"
            };

            project2.Location = new ProjectLocation()
            {
                LocalPath = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2", Type = LocationType.FileSystem, Url = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2"
            };

            repository.Add(project2);
            repository.UnitOfWork.Commit();

            repository = new ProjectsRepository();
            Assert.True(repository.Projects.Count() == 2);

            repository.Remove(repository.Projects.ElementAt(0));
            repository.UnitOfWork.Commit();

            repository = new ProjectsRepository();
            Assert.True(repository.Projects.Count() == 1);
        }
        private void Save(object sender, EventArgs e)
        {
            if (!CheckInput())
            {
                return;
            }

            // Removing relations
            if (_selectedProject != null)
            {
                foreach (var employee in _employeesRepository.GetAll())
                {
                    foreach (var relation in employee.ProjectsList)
                    {
                        if (_selectedProject.Equals(relation.Project))
                        {
                            employee.ProjectsList.Remove(relation);
                            break;
                        }
                    }
                }

                _projectsRepository.Remove(_selectedProject);
            }

            // Adding new project
            var employeesList = addedEmployeesListBox.Items.Cast <Relation>().ToList();

            var projectToAdd = new Project(projectName.Text.TrimAndRemoveMultipleWhiteSpaces(), Convert.ToDateTime(projectStart.Text), Convert.ToDateTime(projectDeadline.Text));

            _projectsRepository.Add(projectToAdd);

            var addedProject = _projectsRepository.GetAll().Find(x => x.Name == projectToAdd.Name);

            // Adding employees to Project.EmployeesList
            foreach (var relation in employeesList)
            {
                addedProject.EmployeesList.Add(relation);
            }

            // Adding projects to relational employees
            foreach (var employee in _employeesRepository.GetAll())
            {
                foreach (var relation in employeesList)
                {
                    if (relation.Employee.Equals(employee))
                    {
                        employee.ProjectsList.Add(new Relation(addedProject, relation.WeeklyWorkHours));
                        break;
                    }
                }
            }

            Close();
        }
        public void Can_save_project()
        {
            var project = new Project()
            {
                Name = "Sample Project",
                Id = Guid.NewGuid(),
                BrowseUrl = "Click to resolve",
                Created = DateTime.Now,
                Version = "1.0.0.0"
            };

            project.Location = new ProjectLocation() { LocalPath = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2", Type = LocationType.FileSystem, Url = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2" };

            // serialize
            var xml = XmlSerializationService<Project>.Serialize(project);


            var repository = new ProjectsRepository();
            repository.Add(project);
            repository.UnitOfWork.Commit();

            repository = new ProjectsRepository();
            Assert.True(repository.Projects.Count() == 1);


            var project2 = new Project()
            {
                Name = "Sample Project 2",
                Id = Guid.NewGuid(),
                BrowseUrl = "Click to resolve",
                Created = DateTime.Now,
                Version = "1.0.0.0"
            };

            project2.Location = new ProjectLocation() { LocalPath = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2", Type = LocationType.FileSystem, Url = @"E:\Program Files (x86)\VirtoCommerce 1.0\Projects\Default2" };

            repository.Add(project2);
            repository.UnitOfWork.Commit();

            repository = new ProjectsRepository();
            Assert.True(repository.Projects.Count() == 2);

            repository.Remove(repository.Projects.ElementAt(0));
            repository.UnitOfWork.Commit();

            repository = new ProjectsRepository();
            Assert.True(repository.Projects.Count() == 1);
        }
Exemplo n.º 6
0
        public void Add_New_Project(object sender, RoutedEventArgs e)
        {
            Modal_New_Project_Error.Visibility = Visibility.Collapsed;
            string project_name = Modal_New_Project_Name.Text;
            string start_date   = Modal_New_Project_Start_Date.SelectedDate.ToString();
            string end_date     = Modal_New_Project_End_Date.SelectedDate.ToString();
            string github       = Modal_New_Project_Github.Text;

            if (_Valid_Name(project_name) == true)
            {
                project_repo.Add(new Project(project_name, 1, start_date, end_date, github));
                DialogResult = true;
                return;
            }
            else
            {
                Modal_New_Project_Error.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 7
0
        private void Create_New_Project(object sender, RoutedEventArgs e)
        {
            _show_error(New_Project_Error, false);
            string project_name = New_Project_Name.Text;
            string start_date   = New_Project_Start_Date.SelectedDate.ToString();
            string end_date     = New_Project_End_Date.SelectedDate.ToString();
            string github       = New_Project_Github.Text;

            if (_Valid_Name(project_name) == false)
            {
                _show_error(New_Project_Error, true);
                return;
            }

            project_repo.Add(new Project(project_name, 1, start_date, end_date, github));
            _show_view(Main_View, false);
            _show_view(Current_Projects_List, true);
            _DatabindProjects(Current_Projects_Listbox, "current");
        }
Exemplo n.º 8
0
        private void UpdateTest()
        {
            var newProject = new ProjectDataMock();

            using (var context = new Context())
            {
                var projectsRepository = new ProjectsRepository(context);
                context.Database.Log = (message) => Debug.WriteLine(message);

                var userStore   = new UserStore <User>(context);
                var userManager = new ApplicationUserManager(userStore);

                var randomUser = UserGenerator.GenerateUser();

                userManager.Create(randomUser, UserGenerator.RandomString());

                newProject.Project.UserId = randomUser.Id;
                newProject.Project.User   = randomUser;

                projectsRepository.Add(newProject.Project);

                _auditTeamDataMock.AuditTeam.ProjectId = newProject.ProjectId;
                _auditTeamDataMock.AuditTeam.AuditorId = newProject.Project.Auditors.First().AuditorId;
            }

            using (var context = new Context())
            {
                var auditTeamRepository = new AuditTeamRepository(context);
                context.Database.Log = (message) => Debug.WriteLine(message);
                auditTeamRepository.Update(_auditTeamDataMock.AuditTeam);
            }

            using (var context = new Context())
            {
                var auditTeamRepository = new AuditTeamRepository(context);
                context.Database.Log = (message) => Debug.WriteLine(message);

                var downloadedAuditTeam = auditTeamRepository.Get(_auditTeamDataMock.AuditTeamId);

                Assert.AreEqual(newProject.ProjectId, downloadedAuditTeam.ProjectId);
                Assert.AreEqual(newProject.Project.Auditors.First().AuditorId, downloadedAuditTeam.AuditorId);
            }
        }
Exemplo n.º 9
0
        private void AddTest()
        {
            using (var context = new Context())
            {
                var projectsRepository = new ProjectsRepository(context);
                context.Database.Log = (message) => Debug.WriteLine(message);

                var userStore   = new UserStore <User>(context);
                var userManager = new ApplicationUserManager(userStore);

                var randomUser = UserGenerator.GenerateUser();

                userManager.Create(randomUser, UserGenerator.RandomString());

                _projectDataMock.Project.UserId = randomUser.Id;
                _projectDataMock.Project.User   = randomUser;

                projectsRepository.Add(_projectDataMock.Project);

                Assert.AreNotEqual(Guid.Empty, _projectDataMock.ProjectId, "Empty guid was return");
            }
        }
Exemplo n.º 10
0
        public ActionResult Create(ProjectViewModel projectViewModel)
        {
            projectViewModel.Technologies = projectViewModel.Technologies.Where(a => a.IsSelected);
            if (projectViewModel.TempProject == false)
            {
                if (projectViewModel.Icon.ImageId < 1)
                {
                    ModelState.AddModelError("IconError", @"Musisz wybrać ikonę");
                }
                else
                {
                    projectViewModel.Icon =
                        _repository.GetAllIcons().First(m => m.ImageId == projectViewModel.Icon.ImageId);
                }
            }
            else
            {
                projectViewModel.Icon = projectViewModel.Icon.ImageId < 1 ?
                                        null : _repository.GetAllIcons().First(m => m.ImageId == projectViewModel.Icon.ImageId);
            }

            projectViewModel.AuthorId = HttpContext.User.Identity.GetUserId();

            Project project = Mapper.Map <ProjectViewModel, Project>(projectViewModel);


            if (ModelState.IsValid)
            {
                _repository.Add(project);

                // return project.TempProject == false ? RedirectToAction("ProjectsManagement") : RedirectToAction("TemporaryProjectsManagement");
                return(RedirectToAction("ScreenshotsManagement", "Image", new { projectId = project.ProjectId }));
            }

            return(View("CreateProject", projectViewModel));
        }
Exemplo n.º 11
0
        private void InitData()
        {
            using (var context = new Context())
            {
                var projectsRepository = new ProjectsRepository(context);
                context.Database.Log = (message) => Debug.WriteLine(message);

                var project = new ProjectDataMock();

                var userStore   = new UserStore <User>(context);
                var userManager = new ApplicationUserManager(userStore);

                var randomUser = UserGenerator.GenerateUser();

                userManager.Create(randomUser, UserGenerator.RandomString());

                project.Project.UserId = randomUser.Id;
                project.Project.User   = randomUser;

                projectsRepository.Add(project.Project);

                _auditTeamDataMock = new AuditTeamDataMock(project.ProjectId, project.Project.Auditors.First().AuditorId);
            }
        }
Exemplo n.º 12
0
        public void GivenThereAreXProjects(string project_type)
        {
            if (project_type == "current")
            {
                ProjectRepo.Add(new Project("angular_project", 1, "02/03/2015", "02/20/2015", "http://github.com/angular_project"));
                ProjectRepo.Add(new Project("js_project", 1, "10/03/2015", "10/20/2015", "http://github.com/js_project"));
                ProjectRepo.Add(new Project("CSharp_project", 1, "02/21/2015", "02/28/2015", "http://github.com/csharp"));

                Assert.AreEqual(3, ProjectRepo.AllCurrentProjects().Count);
            }
            else if (project_type == "past")
            {
                ProjectRepo.Add(new Project("angular_project", 0, "02/03/2015", "02/20/2015", "http://github.com/angular_project"));
                ProjectRepo.Add(new Project("js_project", 0, "10/03/2015", "10/20/2015", "http://github.com/js_project"));
                ProjectRepo.Add(new Project("CSharp_project", 0, "02/21/2015", "02/28/2015", "http://github.com/csharp"));

                Assert.AreEqual(3, ProjectRepo.AllPastProjects().Count);
            }
            else
            {
                throw new ArgumentException("Not a valid project type");
            }
        }
Exemplo n.º 13
0
 public void TestProjectAddFirstProjectToDatabaseWithAllFields()
 {
     Assert.AreEqual(0, repo.GetCount());
     repo.Add(new Project("Simple_Project", 0, "02/31/2015", "04/01/2015", "wwww.github.com/beck410/Simple_Project"));
     Assert.AreEqual(1, repo.GetCount());
 }