public void GetProject_ByGuid_ShouldReturnProjectEntity() { var dataSet = _projectService.Invoke(p => p.ReadProject(Settings.DefaultProjectGuid, DataStoreEnum.WorkingStore)); var result = new BasicProject(); _mapper.Map(dataSet.Project, result); Assert.IsTrue(result.ProjName == Settings.DefaultProjectName); Assert.IsTrue(result.ProjUid == Settings.DefaultProjectGuid); Assert.IsTrue(result.ProjType == ProjectType.Project); Assert.IsTrue(result.WprojDescription == Settings.DefaultProjectName); }
public void GetProject_ByGuid_ShouldReturnDictionaryWithCustomFields() { var projectDataSet = _projectService.Invoke(p => p.ReadProject(Settings.DefaultProjectGuid, DataStoreEnum.WorkingStore)); var customFieldsDataSet = _customFieldsService.Invoke(s => s.ReadCustomFields(string.Empty, false)); var result = new Dictionary <string, object>(); _mapper.Map( projectDataSet.Project, result, new NopPropsMatcher()); _mapper.Map( projectDataSet.ProjectCustomFields, result, new NopPropsMatcher(), externalData: new Dictionary <string, object> { { customFieldsDataSet.DataSetName, customFieldsDataSet }, { "PROJ_UID", result["PROJ_UID"] } }); Assert.IsTrue(((string)result["PROJ_NAME"]).Equals(Settings.DefaultProjectName)); Assert.IsTrue(((string)result["Test - Project - Text"]).Equals("10")); Assert.IsTrue(((decimal)result["Test - Project - Number"]).Equals(20)); Assert.IsTrue(((decimal)result["Test - Project - Cost"]).Equals(3000)); Assert.IsTrue(((int)result["Test - Project - Duration"]).Equals(4000)); Assert.IsTrue(((DateTime)result["Test - Project - Date"]).Equals(DateTime.Parse("1991-02-16", CultureInfo.InvariantCulture))); Assert.IsTrue(((bool)result["Test - Project - YesNo - True"]).Equals(true)); Assert.IsTrue(((bool)result["Test - Project - YesNo - False"]).Equals(false)); }
public void GetTaskDetailsFromStatusingDataSet_ByGuid_ShouldReturnTaskDetailsObject() { var currentDate = DateTime.Now; var changesXml = @" <Changes> <Proj ID='{0}'> <Task ID='{1}'> {2} </Task> </Proj> </Changes>"; var changeXml = @"<Change PID='{0}'>{1}</Change>"; var taskDetails = GetTaskDetailsFromStatusing(); Assert.IsTrue(taskDetails.TaskName == "Task 1"); Assert.IsTrue(taskDetails.TaskWork == 10000); taskDetails.TaskRemWork = 5000; taskDetails.TaskStartDate = currentDate.AddDays(1); taskDetails.TaskFinishDate = currentDate.AddDays(4); var changes = string.Empty; changes += string.Format(changeXml, 184549382, taskDetails.TaskRemWork); changes += string.Format(changeXml, 184549386, taskDetails.TaskStartDate); changes += string.Format(changeXml, 184549387, taskDetails.TaskFinishDate); var xml = string.Format(changesXml, taskDetails.ProjUid, taskDetails.TaskUid, changes); _statusingService.Invoke(s => s.UpdateStatus(xml)); _statusingService.Invoke(s => s.UpdateStatus(xml)); _statusingService.Invoke(s => s.UpdateStatus(xml)); var updatedTaskDetails = GetTaskDetailsFromStatusing(); Assert.IsTrue(updatedTaskDetails.TaskRemWork == updatedTaskDetails.TaskWork); Assert.IsTrue(updatedTaskDetails.TaskRemWork == 5000, "Actual: {0}, Expected: 50", updatedTaskDetails.TaskRemWork); Assert.IsTrue(updatedTaskDetails.TaskStartDate.ToLongDateString() == currentDate.AddDays(1).ToLongDateString()); Assert.IsTrue(updatedTaskDetails.TaskFinishDate.ToLongDateString() == currentDate.AddDays(4).ToLongDateString()); }
public bool Wait(Guid jobUid) { while (true) { var response = _queuePsiService.Invoke(q => q.GetJobCompletionState(new GetJobCompletionStateRequest(jobUid))); var jobState = response.GetJobCompletionStateResult; if (jobState == JobState.Success) { return(true); } if (IsJobEndedAsFailed(jobState)) { return(false); } var aproxSecondsRemaining = _queuePsiService.Invoke(q => q.GetJobWaitTime(jobUid)); Thread.Sleep(aproxSecondsRemaining * 1000); } }
public void CreateProject <T>(T project) { var customFieldsDataSet = _customFieldsPsiService.Invoke(s => s.ReadCustomFieldsByEntity2(PsEntityType.Project.GetAttr <GuidAttribute>().Guid)); var ds = new ProjectDataSet(); _mapper.Map(project, ds.Project); _mapper.Map(project, ds.ProjectCustomFields, externalData: new Dictionary <string, object> { { customFieldsDataSet.DataSetName, customFieldsDataSet }, { "PROJ_UID", ds.Project[0].PROJ_UID } }); var createProjectJobUid = Guid.NewGuid(); _projectPsiService.Invoke(p => p.QueueCreateProject(createProjectJobUid, ds, false)); Wait(createProjectJobUid); var publishProjectJobUid = Guid.NewGuid(); _projectPsiService.Invoke(p => p.QueuePublish(publishProjectJobUid, ds.Project[0].PROJ_UID, true, string.Empty)); Wait(publishProjectJobUid); }
public void DeleteResources(string mask) { try { var resources = _resourcePsiService.Invoke(s => s.ReadResources("", false)); var toDelete = resources.Resources .Cast <ResourceDataSet.ResourcesRow>() .Where(r => r.RES_NAME.StartsWith(mask)) .ToList(); var toCheckout = toDelete .Where(r => r.IsRES_CHECKOUTBYNull()) .Select(r => r.RES_UID) .ToArray(); _resourcePsiService.Invoke(s => s.CheckOutResources(toCheckout)); var deleteResourceJobUid = Guid.NewGuid(); _resourcePsiService.Invoke(s => s.DeleteResources(toDelete.Select(r => r.RES_UID).ToArray(), "Removed by unit tests")); Wait(deleteResourceJobUid); } catch { } }
public void DeleteProject(Guid projectGuid) { try { _statusingPsiService.Invoke(s => s.DeleteStatusingInformationForProject(new[] { projectGuid }, DateTime.MinValue, DateTime.MaxValue)); } catch { } try { var checkInProjectJobUid = Guid.NewGuid(); _projectPsiService.Invoke(p => p.QueueCheckInProject(checkInProjectJobUid, projectGuid, true, Settings.DefaultSessionGuid, "Unit tests session")); Wait(checkInProjectJobUid); } catch { } try { var deleteProjectJobUid = Guid.NewGuid(); _projectPsiService.Invoke(p => p.QueueDeleteProjects(deleteProjectJobUid, true, new[] { projectGuid }, true)); Wait(deleteProjectJobUid); } catch { } }
public void GetProject_ShouldReturnTaskWithCustomFields() { var customFields = _customFieldsService.Invoke(s => s.ReadCustomFieldsByEntity2(PsEntityType.Task.GetAttr <GuidAttribute>().Guid)); var projectDataSet = _projectService.Invoke(s => s.ReadProject(Settings.DefaultProjectGuid, DataStoreEnum.WorkingStore)); var project = new TaskMappingProject(); _mapper.Map(projectDataSet.Project, project); var task = new TaskMappingProjectTask(); _mapper.Map(projectDataSet.Task, task, externalData: new Dictionary <string, object> { { "TASK_UID", task.TaskUid } }); _mapper.Map(projectDataSet.TaskCustomFields, task, externalData: new Dictionary <string, object> { { customFields.DataSetName, customFields }, { "PROJ_UID", Settings.DefaultProjectGuid }, { "TASK_UID", task.TaskUid } }); Assert.IsTrue(task.TaskName == "Task 1"); Assert.IsTrue(task.TestTaskText == "10"); var dict = new Dictionary <string, object>(); _mapper.Map(projectDataSet.Task, dict, new NopPropsMatcher(), externalData: new Dictionary <string, object> { { "TASK_UID", task.TaskUid } }); _mapper.Map(projectDataSet.TaskCustomFields, dict, new NopPropsMatcher(), externalData: new Dictionary <string, object> { { customFields.DataSetName, customFields }, { "PROJ_UID", Settings.DefaultProjectGuid }, { "TASK_UID", task.TaskUid } }); Assert.IsTrue(dict["TASK_NAME"].Equals("Task 1")); Assert.IsTrue(dict["Test - Task - Text"].Equals("10")); var propertiesToUpdate = new Dictionary <string, object> { { "Test - Task - Text", "20" } }; _mapper.Map(propertiesToUpdate, projectDataSet.TaskCustomFields, new NopPropsMatcher(), externalData: new Dictionary <string, object> { { customFields.DataSetName, customFields }, { "PROJ_UID", task.ProjUid }, { "TASK_UID", task.TaskUid } }); _projectService.Invoke(s => s.CheckOutProject(Settings.DefaultProjectGuid, Settings.DefaultSessionGuid, "TaskMapping")); var updateProjectJobUid = Guid.NewGuid(); _projectService.Invoke(s => s.QueueUpdateProject2(updateProjectJobUid, Settings.DefaultSessionGuid, projectDataSet, false)); _envUtil.Wait(updateProjectJobUid); var checkInJobUid = Guid.NewGuid(); _projectService.Invoke(s => s.QueueCheckInProject(checkInJobUid, Settings.DefaultProjectGuid, false, Settings.DefaultSessionGuid, "TaskMapping")); _envUtil.Wait(checkInJobUid); var updatedProjectDs = _projectService.Invoke(s => s.ReadProject(Settings.DefaultProjectGuid, DataStoreEnum.WorkingStore)); var updatedTaskFields = new Dictionary <string, object>(); _mapper.Map(updatedProjectDs.Task, updatedTaskFields, new NopPropsMatcher(), externalData: new Dictionary <string, object> { { "TASK_UID", task.TaskUid } }); _mapper.Map(updatedProjectDs.TaskCustomFields, updatedTaskFields, new NopPropsMatcher(), externalData: new Dictionary <string, object> { { customFields.DataSetName, customFields }, { "PROJ_UID", Settings.DefaultProjectGuid }, { "TASK_UID", task.TaskUid } }); Assert.IsTrue(updatedTaskFields["TASK_NAME"].Equals("Task 1")); Assert.IsTrue(updatedTaskFields["Test - Task - Text"].Equals("20")); }
public static void ClassInit(TestContext context) { _envUtil = new EnvUtil(Settings.PwaUri); _mapper = new FluentMapper(new PsMappingConfiguration()); _projectService = PsiContext.Get <IProject>(Settings.PwaUri); _customFieldsService = PsiContext.Get <ICustomFields>(Settings.PwaUri); ClassCleanup(); var customFields = new List <TaskMappingCustomFields> { new TaskMappingCustomFields { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Task - Text", MdEntTypeUid = PsEntityType.Task.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.String }, new TaskMappingCustomFields { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Task - Number", MdEntTypeUid = PsEntityType.Task.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.Number }, new TaskMappingCustomFields { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Task - Cost", MdEntTypeUid = PsEntityType.Task.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.Cost }, new TaskMappingCustomFields { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Task - Duration", MdEntTypeUid = PsEntityType.Task.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.Duration }, new TaskMappingCustomFields { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Task - Date", MdEntTypeUid = PsEntityType.Task.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.Date }, new TaskMappingCustomFields { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Task - YesNo - True", MdEntTypeUid = PsEntityType.Task.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.YesNo }, new TaskMappingCustomFields { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Task - YesNo - False", MdEntTypeUid = PsEntityType.Task.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.YesNo } }; var project = new TaskMappingProject { ProjUid = Settings.DefaultProjectGuid, ProjName = Settings.DefaultProjectName, ProjType = ProjectType.Project }; var task = new TaskMappingProjectTask { TaskUid = Guid.NewGuid(), ProjUid = Settings.DefaultProjectGuid, TaskName = "Task 1", TaskStartDate = DateTime.Now, TaskFinishDate = DateTime.Now.AddDays(10), TaskWork = 5000.0, TestTaskText = "10", TestTaskNumber = 20, TestTaskCost = 3000, TestTaskDuration = 4000, TestTaskDate = DateTime.Parse("1991-02-16", CultureInfo.InvariantCulture), TestTaskYesNoTrue = true }; _envUtil.CreateCustomFields(customFields); var customFieldsDs = _customFieldsService.Invoke(s => s.ReadCustomFieldsByEntity2(PsEntityType.Task.GetAttr <GuidAttribute>().Guid)); var projectCreateDs = new ProjectDataSet(); _mapper.Map(project, projectCreateDs.Project); _mapper.Map(task, projectCreateDs.Task); _mapper.Map(task, projectCreateDs.TaskCustomFields, externalData: new Dictionary <string, object> { { customFieldsDs.DataSetName, customFieldsDs }, { "PROJ_UID", Settings.DefaultProjectGuid }, { "TASK_UID", task.TaskUid } }); var createProjectJobUid = Guid.NewGuid(); _projectService.Invoke(s => s.QueueCreateProject(createProjectJobUid, projectCreateDs, false)); _envUtil.Wait(createProjectJobUid); var publishProjectJobUid = Guid.NewGuid(); _projectService.Invoke(p => p.QueuePublish(publishProjectJobUid, Settings.DefaultProjectGuid, true, string.Empty)); _envUtil.Wait(publishProjectJobUid); }
public static void ClassInit(TestContext context) { _envUtil = new EnvUtil(PwaUri); _projectService = PsiContext.Get <IProject>(PwaUri); _resourceService = PsiContext.Get <IResource>(PwaUri); _statusingService = PsiContext.Get <IStatusing>(PwaUri); ResGuid = _resourceService.Invoke(s => s.GetCurrentUserUid()); ClassCleanup(); var project = new TaskDetailsProject { ProjUid = ProjectGuid, ProjName = ProjectName, ProjType = (int)ProjectType.Project, WprojDescription = ProjectName, Tasks = new List <TaskDetailsTask> { new TaskDetailsTask { TaskName = "Task 1", TaskWork = 10000, TaskStartDate = DateTime.Now, TaskFinishDate = DateTime.Now.AddDays(3), TaskUid = TaskGuid, ProjUid = ProjectGuid }, new TaskDetailsTask { TaskName = "Task 2", TaskWork = 20000, TaskStartDate = DateTime.Now, TaskFinishDate = DateTime.Now.AddDays(3), TaskUid = Guid.NewGuid(), ProjUid = ProjectGuid }, new TaskDetailsTask { TaskName = "Task 3", TaskWork = 30000, TaskStartDate = DateTime.Now, TaskFinishDate = DateTime.Now.AddDays(3), TaskUid = Guid.NewGuid(), ProjUid = ProjectGuid }, } }; var projectTeamResource = new TaskDetailsProjectTeamResource { ResUid = ResGuid, ProjUid = ProjectGuid, NewResUid = ResGuid }; var assn = new TaskDetailsAssignment { AssnUid = AssnGuid, ResUid = ResGuid, ProjUid = ProjectGuid, TaskUid = TaskGuid }; var projectCreateDs = new ProjectDataSet(); Mapper.Map(project, projectCreateDs.Project); Mapper.Map(project.Tasks, projectCreateDs.Task); var projectTeamDs = new ProjectTeamDataSet(); Mapper.Map(projectTeamResource, projectTeamDs.ProjectTeam); var projectAssnDs = new ProjectDataSet(); Mapper.Map(assn, projectAssnDs.Assignment); var createProjectJobUid = Guid.NewGuid(); _projectService.Invoke(p => p.QueueCreateProjectAndCheckOut(createProjectJobUid, SessionGuid, "Unit tests session", projectCreateDs, false)); _envUtil.Wait(createProjectJobUid); var updateProjectTeamJobUid = Guid.NewGuid(); _projectService.Invoke(p => p.QueueUpdateProjectTeam(updateProjectTeamJobUid, SessionGuid, ProjectGuid, projectTeamDs)); _envUtil.Wait(updateProjectTeamJobUid); //Describe common error : GeneralOnlyInsertsAllowed //https://social.msdn.microsoft.com/Forums/en-US/f6cd2eee-3748-47c1-b199-61872b9288b0/im-getting-error-generalonlyinsertsallowed-when-trying-to-add-a-new-task-to-a-project?forum=project2010custprog var assnUpdateJobUid = Guid.NewGuid(); _projectService.Invoke(s => s.QueueAddToProject(assnUpdateJobUid, SessionGuid, projectAssnDs, false)); _envUtil.Wait(assnUpdateJobUid); var checkInProjectJobUid = Guid.NewGuid(); _projectService.Invoke(p => p.QueueCheckInProject(checkInProjectJobUid, ProjectGuid, false, SessionGuid, "Unit tests session")); _envUtil.Wait(checkInProjectJobUid); var publishProjectJobUid = Guid.NewGuid(); _projectService.Invoke(p => p.QueuePublish(publishProjectJobUid, ProjectGuid, true, string.Empty)); _envUtil.Wait(publishProjectJobUid); var publishSummaryProjectJobUid = Guid.NewGuid(); _projectService.Invoke(p => p.QueuePublishSummary(publishSummaryProjectJobUid, ProjectGuid)); _envUtil.Wait(publishSummaryProjectJobUid); }