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 cfs = new List <BasicProjectCustomField> { new BasicProjectCustomField { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Project - Text", MdEntTypeUid = PsEntityType.Project.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.String }, new BasicProjectCustomField { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Project - Number", MdEntTypeUid = PsEntityType.Project.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.Number }, new BasicProjectCustomField { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Project - Cost", MdEntTypeUid = PsEntityType.Project.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.Cost }, new BasicProjectCustomField { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Project - Duration", MdEntTypeUid = PsEntityType.Project.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.Duration }, new BasicProjectCustomField { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Project - Date", MdEntTypeUid = PsEntityType.Project.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.Date }, new BasicProjectCustomField { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Project - YesNo - True", MdEntTypeUid = PsEntityType.Project.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.YesNo }, new BasicProjectCustomField { MdPropUid = Guid.NewGuid(), MdPropName = "Test - Project - YesNo - False", MdEntTypeUid = PsEntityType.Project.GetAttr <GuidAttribute>().Guid, MdPropTypeEnum = PsDataType.YesNo } }; _envUtil.CreateCustomFields(cfs); var simpleProject = new BasicProject { ProjUid = Settings.DefaultProjectGuid, ProjName = Settings.DefaultProjectName, ProjType = (int)ProjectType.Project, WprojDescription = Settings.DefaultProjectName, TestProjectText = "10", TestProjectNumber = 20, TestProjectCost = 3000, TestProjectDuration = 4000, TestProjectDate = DateTime.Parse("1991-02-16", CultureInfo.InvariantCulture), TestProjectYesNoTrue = true }; _envUtil.CreateProject(simpleProject); }
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); }