public void AddProjectTest()
        {
            var pdata = new List <Project>()
            {
                new Project {
                    Project_ID = 1, ProjectName = "TestProject1", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(1), Priority = 10, ManagerID = 1, IsSuspended = true, noofTasks = 1, noofCompletedTasks = 1, managerDetails = "Manager1"
                },
                new Project {
                    Project_ID = 2, ProjectName = "TestProject2", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(1), Priority = 11, ManagerID = 2, IsSuspended = false, noofTasks = 1, noofCompletedTasks = 1, managerDetails = "Manager1"
                }
            }.AsQueryable();

            var mock = new Mock <DbSet <Project> >();

            mock.As <IQueryable <Project> >().Setup(x => x.Provider).Returns(pdata.Provider);
            mock.As <IQueryable <Project> >().Setup(x => x.Expression).Returns(pdata.Expression);
            mock.As <IQueryable <Project> >().Setup(x => x.ElementType).Returns(pdata.ElementType);
            mock.As <IQueryable <Project> >().Setup(x => x.GetEnumerator()).Returns(pdata.GetEnumerator());


            var context = new Mock <ProjectManagerContext>();

            context.Setup(x => x.projects).Returns(mock.Object);

            var     service = new ProjectRepository(context.Object);
            Project project = new Project {
                Project_ID = 3, ProjectName = "TestProject3", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(1), Priority = 10, ManagerID = 1, IsSuspended = true, noofTasks = 1, noofCompletedTasks = 1, managerDetails = "Manager1"
            };
            var ret = service.AddProject(project);

            Assert.That(ret == "Project added successfully.");
        }
示例#2
0
        public ProjectConfirmationDto AddProject(ProjectCreationDto project)
        {
            var addedProject = ProjectRepository.AddProject(Mapper.Map <Project>(project));

            ProjectRepository.SaveChanges();
            return(Mapper.Map <ProjectConfirmationDto>(addedProject));
        }
        public void TestAddProject()
        {
            try
            {
                var data = new List <ProjectManager.Persistence.Project>()
                {
                }.AsQueryable();

                var mockSet = new Mock <DbSet <ProjectManager.Persistence.Project> >();
                mockSet.As <IQueryable <ProjectManager.Persistence.Project> >().Setup(m => m.Provider).Returns(data.Provider);
                mockSet.As <IQueryable <ProjectManager.Persistence.Project> >().Setup(m => m.Expression).Returns(data.Expression);
                mockSet.As <IQueryable <ProjectManager.Persistence.Project> >().Setup(m => m.ElementType).Returns(data.ElementType);
                mockSet.As <IQueryable <ProjectManager.Persistence.Project> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
                mockSet.As <IQueryable <ProjectManager.Persistence.Project> >().Setup(m => m.Provider).Returns(data.Provider);

                Project project = new Persistence.Project {
                    ProjectName = "My new Project", StartDate = new DateTime(2018, 11, 25), EndDate = DateTime.Now, Priority = 5, ManagerId = 25
                };


                var mockContext = new Mock <ProjectManagerContext>();
                mockContext.Setup(m => m.projects).Returns(mockSet.Object);

                var            service     = new ProjectRepository(mockContext.Object);
                List <Project> projectList = service.GetAllProjects();

                Assert.That(projectList.Count == 0);
                bool ret = service.AddProject(project);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Assert.That(1 == 0);
            }
        }
示例#4
0
        public async Task <ProjectResponseModel> CreateProject([FromBody] CreateProjectModel model)
        {
            ClaimsPrincipal principal = HttpContext.User;
            string          username  = principal.FindFirstValue("username");

            string id = Guid.NewGuid().ToString();

            ProjectDbModel dbModel = new ProjectDbModel
            {
                Id            = id,
                Collaborators = new List <string>(),
                LastEdit      = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                Name          = model.Name,
                Owner         = username
            };
            await _projectRepository.AddProject(dbModel);

            return(new ProjectResponseModel
            {
                Id = id,
                Name = model.Name,
                Collaborators = new List <string>(),
                LastEdit = dbModel.LastEdit,
                Owner = username
            });
        }
        private static async Task TestProjectRepositoryCRUD()
        {
            IProjectRepository repo = new ProjectRepository(_tableName);

            var pA = new Project {
                Id = "A", Name = "Project A", Description = "Desc proj A"
            };

            Console.WriteLine("* Creating project A");
            await repo.AddProject(pA);

            Console.WriteLine("* Retrieving project A");
            var ppA = await repo.GetProject("A");

            if (ppA != null)
            {
                Console.WriteLine(JsonSerializer.Serialize(ppA));
            }
            else
            {
                Console.WriteLine("not found");
            }

            Console.ReadKey();


            pA.Name        = "Project AA";
            pA.Description = "Desc proj AA";
            Console.WriteLine("* Updating project A - renamed to AA");
            await repo.UpdateProject(pA);

            Console.WriteLine("* Retrieving project A after update");
            var pAUpdated = await repo.GetProject("A");

            if (pAUpdated != null)
            {
                Console.WriteLine(JsonSerializer.Serialize(pAUpdated));
            }
            else
            {
                Console.WriteLine("not found");
            }

            Console.ReadKey();

            Console.WriteLine("* Deleting project A");
            await repo.DeleteProject("A");

            Console.WriteLine("* Retrieving project A after deletion");
            var deletedA = await repo.GetProject("A");

            if (deletedA != null)
            {
                Console.WriteLine(JsonSerializer.Serialize(deletedA));
            }
            else
            {
                Console.WriteLine("not found");
            }
        }
        public void ShouldAddProject()
        {
            IProjectRepository repo = new ProjectRepository("connect");
            var project             = repo.AddProject(new Project());

            Assert.AreEqual(project.Id, 1);
            Assert.AreEqual(project.Name, "Testing Project");
        }
        public void WhenProjectsAddedTwice_ListProjectsReturnsProjectOnce()
        {
            repository.AddProject(new ProjectLocator("test-123"));
            repository.AddProject(new ProjectLocator("test-123"));

            var projects = this.repository.ListProjectsAsync().Result;

            Assert.AreEqual(1, projects.Count());
            Assert.AreEqual("test-123", projects.First().ProjectId);
        }
        public ProjectUpdateResult UpdateProject(ProjectModel oProj)
        {
            Status  oStatus = new Status();
            Project proj    = new Project()
            {
                End_Date   = oProj.End_Date,
                Priority   = oProj.Priority,
                Project1   = oProj.ProjectName,
                Start_Date = oProj.Start_Date,
                Status     = oProj.Status
            };

            if (oProj.Project_ID == 0)
            {
                proj    = repoProject.AddProject(proj);
                oStatus = new Status()
                {
                    Message = "Project added successfully", Result = true
                };
            }
            else
            {
                proj.Project_ID = oProj.Project_ID;
                proj            = repoProject.UpdateProject(proj);
                oStatus         = new Status()
                {
                    Message = "Project updated successfully", Result = true
                };
            }
            if (oProj.Manager_ID != null)
            {
                UserRepository repoUser = new UserRepository();
                User           ouser    = repoUser.GetUserById(oProj.Manager_ID.Value);
                ouser.Project_ID = proj.Project_ID;
                repoUser.UpdateUser(ouser);
            }
            return(new ProjectUpdateResult()
            {
                status = oStatus,
                project = new ProjectModel
                {
                    Project_ID = proj.Project_ID,
                    ProjectName = proj.Project1,
                    Priority = proj.Priority,
                    End_Date = proj.End_Date,
                    NumberOfTasks = proj.Tasks.Count,
                    Start_Date = proj.Start_Date,
                    Status = proj.Status
                }
            });
        }
        /// <summary>
        /// To update the project details to db
        /// </summary>
        /// <param name="oProj"></param>
        /// <returns></returns>
        public ProjectUpdateModel UpdateProject(ProjectModel project_Model)
        {
            StatusModel _status = new StatusModel();
            Project     proj    = new Project()
            {
                End_Date   = project_Model.End_Date,
                Priority   = project_Model.Priority,
                Project1   = project_Model.ProjectName,
                Start_Date = project_Model.Start_Date,
                Status     = project_Model.Status
            };

            if (project_Model.Project_ID == 0)
            {
                proj    = repoProject.AddProject(proj);
                _status = new StatusModel()
                {
                    Message = "Project details are added successfully", Result = true
                };
            }
            else
            {
                proj.Project_ID = project_Model.Project_ID;
                proj            = repoProject.UpdateProject(proj);
                _status         = new StatusModel()
                {
                    Message = "Project details are updated successfully", Result = true
                };
            }
            if (project_Model.Manager_ID != null)
            {
                UserRepository repoUser = new UserRepository();
                User           ouser    = repoUser.GetUserById(project_Model.Manager_ID.Value);
                ouser.Project_ID = proj.Project_ID;
                repoUser.UpdateUser(ouser);
            }
            return(new ProjectUpdateModel()
            {
                status = _status,
                project = new BusinessEntities.ProjectModel
                {
                    Project_ID = proj.Project_ID,
                    ProjectName = proj.Project1,
                    Priority = proj.Priority,
                    End_Date = proj.End_Date,
                    NumberOfTasks = proj.Tasks.Count,
                    Start_Date = proj.Start_Date,
                    Status = proj.Status
                }
            });
        }
        public async void TestRepo_ProjectRepository()
        {
            IProjectRepository repo = new ProjectRepository(_tableName, _serviceUrl);

            var list = await repo.GetProjectList();

            Assert.Equal(0, list.Count);

            var item = new Project {
                Id = "Project0001", Name = "ProjectA", Description = "Project A"
            };
            await repo.AddProject(item);

            list = await repo.GetProjectList();

            Assert.Equal(1, list.Count);

            var item0 = list[0];

            Assert.NotNull(item0);
            Assert.Equal("Project0001", item0.Id);
            Assert.Equal("ProjectA", item0.Name);
            Assert.Equal("Project A", item0.Description);

            var found = await repo.GetProject("Project0001");

            Assert.NotNull(found);
            Assert.Equal("Project0001", found.Id);
            Assert.Equal("ProjectA", found.Name);
            Assert.Equal("Project A", found.Description);

            found.Name        = "ProjectAA";
            found.Description = "Project AA";
            await repo.UpdateProject(found);

            var updated = await repo.GetProject("Project0001");

            Assert.NotNull(updated);
            Assert.Equal("Project0001", updated.Id);
            Assert.Equal("ProjectAA", updated.Name);
            Assert.Equal("Project AA", updated.Description);


            await repo.DeleteProject("Project0001");

            var deleted = await repo.GetProject("Project0001");

            Assert.Null(deleted);
        }
示例#11
0
        public void SetUp()
        {
            hkcu.DeleteSubKeyTree(TestKeyPath, false);

            var projectRepository  = new ProjectRepository(hkcu.CreateSubKey(TestKeyPath));
            var settingsRepository = new ConnectionSettingsRepository(projectRepository);

            this.service = new ConnectionSettingsService(settingsRepository);

            // Set some initial project settings.
            projectRepository.AddProject(new ProjectLocator(SampleProjectId));

            var projectSettings = settingsRepository.GetProjectSettings(SampleProjectId);

            projectSettings.RdpDomain.Value = "project-domain";
            settingsRepository.SetProjectSettings(projectSettings);
        }
        public void SubmitProject()
        {
            var response = false;

            if (Id > 0)
            {
                response = ProjectRepository.UpdateProject(ProjectInfo);
            }
            else
            {
                response = ProjectRepository.AddProject(ProjectInfo);
            }
            if (response == true)
            {
                NavigationManager.NavigateTo("projects");
            }
        }
        public void AddProject_Test()
        {
            Project pj = new Project();

            pj.ProjectName = "testproj";
            pj.StartDate   = DateTime.Now;
            pj.EndDate     = DateTime.Now.AddDays(1);
            pj.Priority    = 10;
            pj.UserId      = 1;
            var mockProjRepository = new Mock <IProjectManagerRepository <Project> >(MockBehavior.Strict);

            mockProjRepository.Setup(p => p.Create(pj));
            mockProjRepository.Setup(p => p.SaveChange());
            var objProjRepo = new ProjectRepository(mockProjRepository.Object);

            objProjRepo.AddProject(pj);
            mockProjRepository.Verify(mock => mock.Create(pj), Times.Once());
            mockProjRepository.Verify(mock => mock.SaveChange(), Times.Once());
        }
示例#14
0
        public ActionResult CreateEdit(ProjectVeiwModel project)
        {
            if (ModelState.IsValid)
            {
                if (project.ProjectItem.Id <= 0)
                {
                    var employee = _employeeRepository.GetEmployee(project.ProjectItem.EmployeeId);
                    project.ProjectItem.ContactName = employee.FullName;
                    _projectRepository.AddProject(project.ProjectItem);
                }
                else
                {
                    _projectRepository.UpdateProject(project.ProjectItem);
                }

                return(RedirectToAction("Index"));
            }

            return(View(project));
        }
示例#15
0
 public IActionResult Post(Project prj)
 {
     _repo.AddProject(prj);
     return(Ok("Project Added"));
 }
示例#16
0
 // POST api/values
 public void Post(Project project)
 {
     _repository.AddProject(project);
 }
示例#17
0
 public override void Execute(ProjectRepository repository, IConsole console)
 {
     repository.AddProject(_projectId);
 }
示例#18
0
 public void AddProject(string projectName)
 {
     ProjectRepository.AddProject(projectName);
 }
示例#19
0
 public void AddProject(Project project)
 {
     ProjectRepository.AddProject(project);
 }