private static async Task TestPhaseChange(string startPhases, string changedPhases, string[] ignorePhases = null) { // Ensure the projects are there await ProjectClient.EnsureTestProjects(); // DATA SET UP ------------------------------- // Reconfigure the categories var categoriesBackup = await PortfolioConfigClient.UpdatePhasesAsync(TestSettings.TestPortfolio, startPhases); Assert.AreEqual(PhaseBackup, categoriesBackup); GetProjectQueryDTO options = await PortfolioConfigClient.GetFilterOptionsAsync(TestSettings.TestPortfolio); var phaseOptions = options.Options.PhaseItems; if (ignorePhases != null) { phaseOptions.RemoveAll(p => ignorePhases.Contains(p.Display)); } List <ProjectUpdateModel> updates = new List <ProjectUpdateModel>(); Action <ProjectUpdateModel, string> ensurePhase = (p, ph) => { if (p.phase != ph) { p.phase = ph; updates.Add(p); } }; var testProjects = await ProjectClient.GetTestProjectsAsync(); int ci = 0; for (int i = 0; i < ProjectClient.TestProjectCount; i++) { ensurePhase(testProjects[i], phaseOptions[ci++].Value); if (ci >= phaseOptions.Count) { ci = 0; } } await ProjectClient.UpdateProjectsAsync(updates); updates.Clear(); // CHANGE CATEGORIES ------------------------------- categoriesBackup = await PortfolioConfigClient.UpdatePhasesAsync(TestSettings.TestPortfolio, changedPhases); Assert.AreEqual(startPhases, categoriesBackup); // Restore the categories categoriesBackup = await PortfolioConfigClient.UpdatePhasesAsync(TestSettings.TestPortfolio, categoriesBackup); Assert.AreEqual(changedPhases, categoriesBackup); }
public static async Task CleanupTest() { await ProjectClient.DeleteTestProjectsAsync(); await PortfolioConfigClient.UpdatePhasesAsync(TestSettings.TestPortfolio, PhaseBackup); }