Esempio n. 1
0
        public static async Task <ProjectTestData> LoadAsync(string projectId)
        {
            var project = new ProjectTestData(projectId);
            await project.LoadAsync();

            return(project);
        }
        public async Task UpdateCategoryWithHistoryCheck()
        {
            var         projectId               = TestSettings.TestProjectId;
            var         testCategory            = "EXTRA CATEGORY";
            string      originalCategoryViewKey = null;
            Func <Task> updateCategory          = async() => {
                originalCategoryViewKey = await UpdateProjectCategory(projectId, testCategory);
            };

            // Test procedure:
            // 1. Update config to add the category
            // - at the midpoint, update the project to use the test category
            // - config then resets - but category is in use so is only hidden
            await ConfigurationTestUtils.TestCollectionLabel(ProjectPropertyConstants.category, testCategory, midpointTest : updateCategory);

            // 2. Update the project to not use the label
            var project = await ProjectTestData.LoadAsync(projectId);

            project.ProjectUpdate.category = originalCategoryViewKey;
            await project.UpdateAsync();

            // 3. Check the option has disappeared.
            await project.LoadAsync();

            var categoryItem = project.DTO.Options.CategoryItems.SingleOrDefault(i => i.Display == testCategory);

            Assert.IsNull(categoryItem);

            // 4. Do a no-change update on config (hidden option should be removed - but no way to verify!)
            var config = await ConfigTestData.LoadAsync(TestSettings.TestPortfolio);

            await config.UpdateAsync();
        }
Esempio n. 3
0
        public ProjectTestData Clone()
        {
            var clone = new ProjectTestData(projectId);

            clone.DTO           = TestMapper.ProjectMapper.Map <GetProjectDTO <ProjectEditViewModel> >(DTO);
            clone.ProjectUpdate = TestMapper.ProjectMapper.Map <ProjectUpdateModel>(clone.ProjectEditView);
            return(clone);
        }
        public async Task UpdateWithNoChange()
        {
            var project = await ProjectTestData.LoadAsync(TestProjectId);

            var projectUpdate = project.Clone();
            await projectUpdate.UpdateAsync();

            var afterproject = await ProjectTestData.LoadAsync(TestProjectId);

            CompareUtil.Compare(project.ProjectEditView, afterproject.ProjectEditView);
        }
        private async Task <string> UpdateProjectCategory(string projectId, string categoryName)
        {
            // 1. GET PROJECT
            var initial = await ProjectTestData.LoadAsync(projectId);

            var originalCategoryViewKey = initial.DTO.Project.category;
            var categoryItem            = initial.DTO.Options.CategoryItems.Single(i => i.Display == categoryName);

            // 2. UPDATE PROJECT category
            var update = initial.Clone();

            update.ProjectUpdate.category = categoryItem.Value;
            await update.UpdateAsync();

            // 3. Check the option is present
            await update.LoadAsync();

            Assert.AreEqual(categoryItem.Value, update.DTO.Project.category);

            return(originalCategoryViewKey);
        }