コード例 #1
0
        public async Task RecentTemplates_TwoTemplatesInGroupDifferentLanguage_TreatedAsDifferentRecentTemplate()
        {
            CreateCategories("android", "app", "general");
            CreateCategorizer();
            SolutionTemplate template1 = AddTemplate("template-id1", "android/app/general");

            template1.GroupId  = "console";
            template1.Language = "C#";
            SolutionTemplate template2 = AddTemplate("template-id2", "android/app/general");

            template2.GroupId  = "console";
            template2.Language = "F#";
            CategorizeTemplates();
            recentlyUsedTemplatesFile = GetRecentlyUsedTemplatesFileName("TwoTemplatesInGroupDifferentLanguage.xml");
            var recentTemplates            = new RecentTemplates(recentlyUsedTemplatesFile);
            var initialRecentTemplatesList = recentTemplates.GetTemplates(categorizedTemplates);

            recentTemplates.AddTemplate(template1);
            recentTemplates.AddTemplate(template2);

            var recentTemplatesList = await GetRecentTemplates(recentTemplates, categorizedTemplates, 2);

            Assert.AreEqual(0, initialRecentTemplatesList.Count);
            Assert.AreEqual(2, recentTemplatesList.Count);
            Assert.AreEqual(template2, recentTemplatesList[0]);
            Assert.AreEqual(template1, recentTemplatesList[1]);
        }
コード例 #2
0
        /// <summary>
        /// The RecentTemplates class uses the RecentFileStorage class. In the
        /// RecentFileStorage class constructor a task is started to create a file
        /// and may finish whilst the unit test is adding a new template. This task
        /// delay can cause the cached in-memory list in the RecentFileStorage to be
        /// cleared. This causes the test to fail since it will run before the
        /// in-memory list can be updated when the RecentFileStorage class saves the
        /// file to disk. This saving to file is delayed by a second. So we retry
        /// getting the templates from the RecentTemplates until a timeout occurs.
        /// Most of the time the RecentTemplates.GetTemplates method works first
        /// time and returns the expected templates.
        /// </summary>
        static async Task <IList <SolutionTemplate> > GetRecentTemplates(
            RecentTemplates recentTemplates,
            List <TemplateCategory> categorizedTemplates,
            int expectedTemplateCount)
        {
            const int MAX_WAIT_TIME = 5000;
            const int RETRY_WAIT    = 100;

            int remainingTries = MAX_WAIT_TIME / RETRY_WAIT;

            while (remainingTries > 0)
            {
                var recentTemplatesList = recentTemplates.GetTemplates(categorizedTemplates);
                if (recentTemplatesList.Count == expectedTemplateCount)
                {
                    return(recentTemplatesList);
                }

                // Wait for recent file storage to be updated.
                await Task.Delay(RETRY_WAIT);

                remainingTries--;
            }
            return(new List <SolutionTemplate> ());
        }
コード例 #3
0
 public TemplatingService()
 {
     RecentTemplates = new RecentTemplates();
     AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/ProjectTemplateCategories", OnTemplateCategoriesChanged);
     AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/ProjectTemplatingProviders", OnTemplatingProvidersChanged);
     AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/ProjectTemplateWizards", OnProjectTemplateWizardsChanged);
     AddinManager.AddExtensionNodeHandler("/MonoDevelop/Ide/TemplateImages", OnTemplateImagesChanged);
 }
コード例 #4
0
        public ProcessedTemplateResult ProcessTemplate(SolutionTemplate template, NewProjectConfiguration config, SolutionFolder parentFolder)
        {
            IProjectTemplatingProvider provider = GetTemplatingProviderForTemplate(template);

            if (provider != null)
            {
                var result = provider.ProcessTemplate(template, config, parentFolder);
                if (result.WorkspaceItems.Any())
                {
                    RecentTemplates.AddTemplate(template);
                }
                return(result);
            }
            return(null);
        }